home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / x / volume9 / acm / part01 next >
Encoding:
Internet Message Format  |  1990-10-09  |  65.4 KB

  1. Path: uunet!snorkelwacker!apple!netcom!amdcad!sun!mipsdal.mips.com
  2. From: riley@mipsdal.mips.com (Riley Rainey)
  3. Newsgroups: comp.sources.x
  4. Subject: v09i069: acm, X aerial combat simulation, Part01/05
  5. Message-ID: <csx-09i069:acm@uunet.UU.NET>
  6. Date: 7 Oct 90 18:12:48 GMT
  7. Sender: news@sun.Eng.Sun.COM
  8. Lines: 2490
  9. Approved: argv@sun.com
  10.  
  11. Submitted-by: riley@mipsdal.mips.com (Riley Rainey)
  12. Posting-number: Volume 9, Issue 69
  13. Archive-name: acm/part01
  14.  
  15. acm is a multi-user aerial combat simulation written for X.  The sources
  16. are in shar format broken into 5 parts.  acm requires an 8-plane color
  17. display and a reasonably fast (> 10 SPECmark) workstation to perform
  18. reasonably well.
  19.  
  20. To unpack these shar format files, first save each article as acm.shar.N,
  21. where N is the part number, delete the headers and trailers from each file,
  22. and then type:
  23.  
  24.     $ cat acm.shar.* | sh
  25.  
  26. acm is divided into two directories, V and fsim. V contains the 3-D routines
  27. and fsim is everything else.  V must be "made" first.
  28.  
  29. ------->  CUT HERE  <---------
  30. mkdir V
  31. mkdir V/test
  32. mkdir V/lib
  33. mkdir fsim
  34. echo x - ./V
  35. sed 's/^X//' >./V <<'*-*-END-of-./V-*-*'
  36. *-*-END-of-./V-*-*
  37. echo x - ./V/lib
  38. sed 's/^X//' >./V/lib <<'*-*-END-of-./V/lib-*-*'
  39. *-*-END-of-./V/lib-*-*
  40. echo x - ./V/lib/Makefile
  41. sed 's/^X//' >./V/lib/Makefile <<'*-*-END-of-./V/lib/Makefile-*-*'
  42. X# Makefile generated by imake - do not edit!
  43. X# $XConsortium: imake.c,v 1.37 88/10/08 20:08:30 jim Exp $
  44. X
  45. X###########################################################################
  46. X# X Window System Makefile generated from template file Imake.tmpl
  47. X# $XConsortium: Imake.tmpl,v 1.91 88/10/23 22:37:10 jim Exp $
  48. X#
  49. X# Do not change the body of the imake template file.  Server-specific
  50. X# parameters may be set in the appropriate .macros file; site-specific
  51. X# parameters (but shared by all servers) may be set in site.def.  If you
  52. X# make any changes, you'll need to rebuild the makefiles using
  53. X# "make World" (at best) or "make Makefile; make Makefiles" (at least) in
  54. X# the top level directory.
  55. X#
  56. X# If your C preprocessor doesn't define any unique symbols, you'll need
  57. X# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
  58. X# "make Makefile", "make Makefiles", or "make World").
  59. X#
  60. X# If you absolutely can't get imake to work, you'll need to set the
  61. X# variables at the top of each Makefile as well as the dependencies at the
  62. X# bottom (makedepend will do this automatically).
  63. X#
  64. X
  65. X###########################################################################
  66. X# platform-specific configuration parameters - edit Mips.macros to change
  67. X
  68. X# platform:  $XConsortium: Mips.macros,v 1.27 88/10/23 11:00:43 jim Exp $
  69. X
  70. X             AS = as
  71. X             CC = cc
  72. X            CPP = /lib/cpp
  73. X             LD = ld
  74. X           LINT = lint
  75. X        INSTALL = /etc/mipsinstall
  76. X           TAGS = ctags
  77. X             RM = rm -f
  78. X             MV = mv
  79. X             LN = ln -s
  80. X         RANLIB = ranlib
  81. XRANLIBINSTFLAGS =
  82. X             AR = ar clq
  83. X             LS = ls
  84. X       LINTOPTS = -axz
  85. X    LINTLIBFLAG = -C
  86. X           MAKE = make
  87. XSTD_CPP_DEFINES = -DSYSV
  88. X    STD_DEFINES = -I$(XLIBSRC)/mips -I/usr/include/bsd -DSYSV
  89. X
  90. XSYSAUX_LIBRARIES = -lbsd -lmld
  91. X
  92. X  INSTFILEFLAGS = -f
  93. X
  94. X###########################################################################
  95. X# site-specific configuration parameters - edit site.def to change
  96. X
  97. X# site:  $XConsortium: site.def,v 1.16 88/10/12 10:30:24 jim Exp $
  98. X
  99. X###########################################################################
  100. X# definitions common to all Makefiles - do not edit
  101. X
  102. X          SHELL =     /bin/sh
  103. X
  104. X         MFLAGS = -$(MAKEFLAGS)
  105. X
  106. X        DESTDIR =
  107. X      USRLIBDIR = $(DESTDIR)/usr/lib
  108. X         BINDIR = $(DESTDIR)/usr/bin/X11
  109. X         INCDIR = $(DESTDIR)/usr/include/X11
  110. X         ADMDIR = $(DESTDIR)/usr/adm
  111. X         LIBDIR = $(USRLIBDIR)/X11
  112. X     LINTLIBDIR = $(USRLIBDIR)/lint
  113. X        FONTDIR = $(LIBDIR)/fonts
  114. X       XINITDIR = $(LIBDIR)/xinit
  115. X         XDMDIR = $(LIBDIR)/xdm
  116. X         UWMDIR = $(LIBDIR)/uwm
  117. X         AWMDIR = $(LIBDIR)/awm
  118. X         TWMDIR = $(LIBDIR)/twm
  119. X        MANPATH = $(DESTDIR)/usr/man
  120. X  MANSOURCEPATH = $(MANPATH)/man
  121. X         MANDIR = $(MANSOURCEPATH)1
  122. X      LIBMANDIR = $(MANSOURCEPATH)3
  123. X    XAPPLOADDIR = $(LIBDIR)/app-defaults
  124. X
  125. X   INSTBINFLAGS = -m 0755
  126. X   INSTUIDFLAGS = -m 4755
  127. X   INSTLIBFLAGS = -m 0664
  128. X   INSTINCFLAGS = -m 0444
  129. X   INSTMANFLAGS = -m 0444
  130. X   INSTAPPFLAGS = -m 0444
  131. X  INSTKMEMFLAGS = -m 4755
  132. X        FCFLAGS = -t
  133. X    CDEBUGFLAGS =
  134. X
  135. X        PATHSEP = /
  136. X         DEPEND = $(DEPENDSRC)/makedepend
  137. X          IMAKE = $(IMAKESRC)/imake
  138. X            RGB = $(RGBSRC)/rgb
  139. X             FC = $(BDFTOSNFSRC)/bdftosnf
  140. X      MKFONTDIR = $(MKFONTDIRSRC)/mkfontdir
  141. X      MKDIRHIER = $(SCRIPTSSRC)/mkdirhier.sh
  142. X
  143. X         CFLAGS = $(CDEBUGFLAGS) $(INCLUDES) $(STD_DEFINES) $(DEFINES)
  144. X      LINTFLAGS = $(LINTOPTS) $(INCLUDES) $(STD_DEFINES) $(DEFINES) -DLINT
  145. X        LDFLAGS = $(CDEBUGFLAGS) $(SYS_LIBRARIES) $(SYSAUX_LIBRARIES)
  146. X            TOP = /people/riley/R3
  147. X      CLIENTSRC = $(TOP)/clients
  148. X        DEMOSRC = $(TOP)/demos
  149. X         LIBSRC = $(TOP)/lib
  150. X        FONTSRC = $(TOP)/fonts
  151. X     INCLUDESRC = $(TOP)/X11
  152. X      SERVERSRC = $(TOP)/server
  153. X        UTILSRC = $(TOP)/util
  154. X     SCRIPTSSRC = $(UTILSRC)/scripts
  155. X     EXAMPLESRC = $(TOP)/examples
  156. X     CONTRIBSRC = $(TOP)/contrib
  157. X         DOCSRC = $(TOP)/doc
  158. X         RGBSRC = $(TOP)/rgb
  159. X      DEPENDSRC = $(UTILSRC)/makedepend
  160. X       IMAKESRC = $(UTILSRC)/imake
  161. X       IRULESRC = $(UTILSRC)/imake.includes
  162. X        XLIBSRC = $(LIBSRC)/X
  163. X         XMUSRC = $(LIBSRC)/Xmu
  164. X     TOOLKITSRC = $(LIBSRC)/Xt
  165. X     AWIDGETSRC = $(LIBSRC)/Xaw
  166. X     OLDXLIBSRC = $(LIBSRC)/oldX
  167. X    BDFTOSNFSRC = $(FONTSRC)/bdftosnf
  168. X   MKFONTDIRSRC = $(FONTSRC)/mkfontdir
  169. X   EXTENSIONSRC = $(TOP)/extensions
  170. X   EXTENSIONLIB = $(EXTENSIONSRC)/lib/libXext.a
  171. X           XLIB = $(XLIBSRC)/libX11.a
  172. X         XMULIB = $(XMUSRC)/libXmu.a
  173. X        OLDXLIB = $(OLDXLIBSRC)/liboldX.a
  174. X       XTOOLLIB = $(TOOLKITSRC)/libXt.a
  175. X         XAWLIB = $(AWIDGETSRC)/libXaw.a
  176. X       LINTXLIB = $(XLIBSRC)/llib-lX11.ln
  177. X        LINTXMU = $(XMUSRC)/llib-lXmu.ln
  178. X      LINTXTOOL = $(TOOLKITSRC)/llib-lXt.ln
  179. X        LINTXAW = $(AWIDGETSRC)/llib-lXaw.ln
  180. X       INCLUDES = -I$(TOP)
  181. X      MACROFILE = Mips.macros
  182. X   ICONFIGFILES = $(IRULESRC)/Imake.tmpl \
  183. X            $(IRULESRC)/$(MACROFILE) $(IRULESRC)/site.def
  184. X  IMAKE_DEFINES =
  185. X      IMAKE_CMD = $(NEWTOP)$(IMAKE) -TImake.tmpl -I$(NEWTOP)$(IRULESRC) \
  186. X            -s Makefile $(IMAKE_DEFINES)
  187. X         RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a \
  188. X            .emacs_* tags TAGS make.log MakeOut
  189. X
  190. X###########################################################################
  191. X# rules:  $XConsortium: Imake.rules,v 1.71 88/10/23 22:46:34 jim Exp $
  192. X
  193. X###########################################################################
  194. X# start of Imakefile
  195. X
  196. XCDEBUGFLAGS = -O2
  197. XLIBOBJS    = \
  198. X      VOpenViewport.o \
  199. X      VResizeViewport.o \
  200. X      VCloseViewport.o \
  201. X      VGetEyeSpace.o \
  202. X      VGetPlanes.o \
  203. X      VReadObject.o \
  204. X      VWriteObject.o \
  205. X      VAllocColor.o \
  206. X      VBindColors.o \
  207. X      VExposeBuffer.o \
  208. X      VCreatePolygon.o \
  209. X      VCreatePoints.o \
  210. X      VCopyPolygon.o \
  211. X      VDrawPolygon.o \
  212. X      VFillPolygon.o \
  213. X      VDrawString.o \
  214. X      VClipPolygon.o \
  215. X      VDotProd.o \
  216. X      VRotate.o \
  217. X      VTransformPolygon.o \
  218. X      VTransform.o \
  219. X      VIdentMatrix.o \
  220. X      VMatrixMult.o \
  221. X      VMatrixDeterminant.o \
  222. X      VMatrixInvert.o \
  223. X      VPrintPolygon.o \
  224. X      Vmalloc.o
  225. X
  226. Xall:: libV.a
  227. X
  228. XlibV.a: $(LIBOBJS)
  229. X    $(RM) $@
  230. X    $(AR) $@ $(LIBOBJS)
  231. X    $(RANLIB) $@
  232. X
  233. Xinstall:: libV.a
  234. X    $(INSTALL) -c $(INSTLIBFLAGS) libV.a $(USRLIBDIR)
  235. X    $(RANLIB) $(RANLIBINSTFLAGS) $(USRLIBDIR)/libV.a
  236. X
  237. X# DO NOT DELETE THIS LINE -- make depend depends on it.
  238. X
  239. X###########################################################################
  240. X# Imake.tmpl common rules for all Makefiles - do not edit
  241. X
  242. Xemptyrule::
  243. X
  244. Xclean::
  245. X    $(RM_CMD) \#*
  246. X
  247. XMakefile:: $(IMAKE)
  248. X
  249. XMakefile:: Imakefile \
  250. X    $(IRULESRC)/Imake.tmpl \
  251. X    $(IRULESRC)/Imake.rules \
  252. X    $(IRULESRC)/site.def \
  253. X    $(IRULESRC)/$(MACROFILE)
  254. X    -@if [ -f Makefile ]; then \
  255. X        echo "$(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \
  256. X        $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
  257. X    else exit 0; fi
  258. X    $(IMAKE_CMD) -DTOPDIR=$(TOP)
  259. X
  260. X$(IMAKE):
  261. X    @echo "making $@"; \
  262. X    cd $(IMAKESRC); $(MAKE) BOOTSTRAPCFLAGS=$(BOOTSTRAPCFLAGS)
  263. X
  264. Xtags::
  265. X    $(TAGS) -w *.[ch]
  266. X    $(TAGS) -xw *.[ch] > TAGS
  267. X
  268. X###########################################################################
  269. X# empty rules for directories that do not have SUBDIRS - do not edit
  270. X
  271. Xinstall::
  272. X    @echo "install done"
  273. X
  274. Xinstall.man::
  275. X    @echo "install.man done"
  276. X
  277. XMakefiles::
  278. X
  279. X###########################################################################
  280. X# dependencies generated by makedepend
  281. X
  282. *-*-END-of-./V/lib/Makefile-*-*
  283. echo x - ./V/lib/VPrintPolygon.c
  284. sed 's/^X//' >./V/lib/VPrintPolygon.c <<'*-*-END-of-./V/lib/VPrintPolygon.c-*-*'
  285. X#include "Vlib.h"
  286. X
  287. Xvoid    VPrintPolygon (file, p)
  288. XFILE    *file;
  289. XVPolygon *p; {
  290. X
  291. X    int    i;
  292. X    char    *nullPoly = "*** Null Polygon ***\n";
  293. X
  294. X    if (p == (VPolygon *) NULL)
  295. X        fprintf (file, nullPoly);
  296. X    else {
  297. X        if (p->numVtces == 0) {
  298. X            fprintf (file, nullPoly);
  299. X            return;
  300. X        }
  301. X
  302. X        fprintf (file, "%d vertices:\n", p->numVtces);
  303. X
  304. X        for (i=0; i<p->numVtces; ++i)
  305. X            fprintf(file, "%9.6g %9.6g %9.6g\n", p->vertex[i].x,
  306. X                p->vertex[i].y, p->vertex[i].z);
  307. X    }
  308. X
  309. X    return;
  310. X}
  311. *-*-END-of-./V/lib/VPrintPolygon.c-*-*
  312. echo x - ./V/lib/Vlib.h
  313. sed 's/^X//' >./V/lib/Vlib.h <<'*-*-END-of-./V/lib/Vlib.h-*-*'
  314. X#ifndef __Vlib
  315. X#define __Vlib
  316. X
  317. X#define VmaxVP    32        /* max # of vertices in a polygon */
  318. X
  319. X#define MAXCOLORS 8        /* max number of colors available */
  320. X                /* when double buffering */
  321. X#if (MAXCOLORS==4)
  322. X#define PLANES 2
  323. X#endif
  324. X#if (MAXCOLORS==8)
  325. X#define PLANES 3
  326. X#endif
  327. X#if (MAXCOLORS==16)
  328. X#define PLANES 4
  329. X#endif
  330. X
  331. X#include <X11/Xlib.h>
  332. X#include <stdio.h>
  333. X#include <memory.h>
  334. X
  335. Xtypedef struct _vcolor {
  336. X    char    *color_name;    /* text name */
  337. X    short    index;        /* index into pixel value table */
  338. X    XColor    xcolor;        /* representation of this color */
  339. X    struct _vcolor *next;
  340. X    } VColor;
  341. X
  342. Xtypedef struct {
  343. X    double    x, y, z;    /* A point or vector in 3-space */
  344. X    } VPoint;
  345. X
  346. Xtypedef struct {
  347. X    short    numVtces;    /* vertex count */
  348. X    VPoint    *vertex;    /* pointer to array of vertices */
  349. X    VColor    *color;        /* pointer to color descriptor */
  350. X    } VPolygon;
  351. X
  352. Xtypedef struct {
  353. X    char    *name;        /* object name */
  354. X    int    numPolys;    /* polygon count */
  355. X    VPolygon **polygon;    /* pointer to array of polygon pointers */
  356. X    } VObject;
  357. X
  358. Xtypedef struct {
  359. X    double    m[4][4];
  360. X    } VMatrix;
  361. X
  362. Xtypedef struct {
  363. X    unsigned long flags;    /* viewport flags */
  364. X    VMatrix      eyeSpace;    /* transforms from world to eyeSpace system */
  365. X    VPolygon  *clipPoly;    /* planes to clip viewed polygons */
  366. X    double      units;    /* world units expressed in meters */
  367. X    double      dist;        /* distance in units from eye to screen */
  368. X    double      xres;        /* x screen resolution in dots per unit */
  369. X    double      yres;        /* y screen resolution in dots per unit */
  370. X    int      width;    /* width of window in dots */
  371. X    int      height;    /* height of window in dots */
  372. X    VPoint      Middl;    /* center of window */
  373. X    VPoint      Scale;    /* scaling factor */
  374. X    Display      *dpy;        /* Display associated with this viewport */
  375. X    int      screen;    /* X screen number */
  376. X    Window      *win;
  377. X    Pixmap      monoPixmap;    /* Pixmap used to buffer monochrome drawing */
  378. X
  379. X    int      colors;    /* color count */
  380. X    int      set;        /* id of buffer currently in use */
  381. X    unsigned long mask;    /* current plane mask */
  382. X    unsigned long aMask, bMask;
  383. X    unsigned long *pixel;    /* current pixel drawing values */
  384. X    unsigned long aPixel[MAXCOLORS];
  385. X    unsigned long bPixel[MAXCOLORS];
  386. X    XColor      aColor[MAXCOLORS*MAXCOLORS];
  387. X    XColor      bColor[MAXCOLORS*MAXCOLORS];
  388. X    Colormap  cmap;
  389. X    } Viewport;
  390. X
  391. X#define VGetPolygonPixel(p)        (p->color->xcolor.pixel)
  392. X#define VLookupViewportColor(v,n)    (v->pixel[n])
  393. X#define VGetViewportMask(v)         (v->mask)
  394. X
  395. X/*
  396. X *  Globals
  397. X */
  398. X
  399. XVColor   *VColorList;        /* list of colors needed for drawing */
  400. X
  401. X/*
  402. X *  V macros and function prototypes
  403. X */
  404. X
  405. X#define VDestroyPoints(a)    free((char *) a)
  406. X#define VDestroyPolygon(a)    {free((char *) a->vertex); free((char *) a);}
  407. X
  408. XViewport *VOpenViewport();     /* (Display *, .. ) */
  409. Xvoid     VResizeViewport();    /* (Viewport *, ... ) */
  410. Xvoid     VCloseViewport();    /* (Viewport *) */
  411. XVPolygon *VCreatePolygon();    /* (VPoint *, int, VColor *) */
  412. XVPolygon *VCopyPolygon();    /* (VPolygon *) */
  413. XVPolygon *VClipPolygon();    /* (VPolygon *, VPoint) */
  414. XVPoint     *VCreatePoints();    /* (int) */
  415. XVColor     *VAllocColor();    /* (char *) */
  416. Xint     VBindColors();        /* (Viewport *, char *) */
  417. Xvoid     VExposeBuffer();    /* (Viewport *, GC) */
  418. XVObject     *VReadObject();    /* (FILE *) */
  419. Xint     VWriteObject();    /* (FILE *, VObject *) */
  420. XVMatrix     *VRotate();        /* (VMatrix *, int) */
  421. XVMatrix  *VTranslate();        /* (VMatrix *, double, double, double) */
  422. XVMatrix  *VTranslatePoint();    /* (VMatrix *, VPoint) */
  423. Xdouble     VMatrixDeterminant();    /* (VMatrix *) */
  424. XVMatrix  *VMatrixInvert();    /* (VMatrix *, VMatrix *) */
  425. Xvoid     VTransform();        /* (VPoint *, VMatrix *, VPoint *) */
  426. Xdouble     VDotProd();        /* (Vpoint *, VPoint *) */
  427. Xchar     *Vmalloc();        /* (int) */
  428. X
  429. X/*
  430. X *  Viewport flags (must be changed manually after VOpenViewport for now)
  431. X */
  432. X
  433. X#define    VPClip        1    /* polygons should be clipped before drawing */
  434. X#define VPPerspective    2    /* Z coordinate used for depth information */
  435. X#define VPMono        4    /* Monochrome environment */
  436. X
  437. X/*
  438. X *  VRotate options
  439. X */
  440. X
  441. X#define XRotation    1    /* rotate about X axis */
  442. X#define YRotation    2    /* rotate about Y axis */
  443. X#define ZRotation    3    /* rotate about Z axis */
  444. X
  445. X#endif
  446. *-*-END-of-./V/lib/Vlib.h-*-*
  447. echo x - ./V/lib/VCreatePolygon.c
  448. sed 's/^X//' >./V/lib/VCreatePolygon.c <<'*-*-END-of-./V/lib/VCreatePolygon.c-*-*'
  449. X#include "Vlib.h"
  450. X
  451. XVPolygon *VCreatePolygon (numVtces, vert, color)
  452. Xint    numVtces;
  453. XVPoint    *vert;
  454. XVColor    *color; {
  455. X
  456. X    VPolygon *p;
  457. X
  458. X    p = (VPolygon *) Vmalloc (sizeof (VPolygon));
  459. X
  460. X    p->numVtces = numVtces;
  461. X    p->vertex = (VPoint *) Vmalloc (sizeof (VPoint) * numVtces);
  462. X    memcpy ((char *) p->vertex, (char *) vert, sizeof(VPoint) * numVtces);
  463. X    p->color = color;
  464. X
  465. X    return p;
  466. X}
  467. *-*-END-of-./V/lib/VCreatePolygon.c-*-*
  468. echo x - ./V/lib/VCreatePoints.c
  469. sed 's/^X//' >./V/lib/VCreatePoints.c <<'*-*-END-of-./V/lib/VCreatePoints.c-*-*'
  470. X#include "Vlib.h"
  471. X
  472. XVPoint *VCreatePoints (numPts)
  473. Xint    numPts; {
  474. X
  475. X    return (VPoint *) Vmalloc (sizeof(VPoint) * numPts);
  476. X}
  477. *-*-END-of-./V/lib/VCreatePoints.c-*-*
  478. echo x - ./V/lib/VCopyPolygon.c
  479. sed 's/^X//' >./V/lib/VCopyPolygon.c <<'*-*-END-of-./V/lib/VCopyPolygon.c-*-*'
  480. X#include "Vlib.h"
  481. X
  482. XVPolygon *VCopyPolygon (poly)
  483. XVPolygon *poly; {
  484. X
  485. X    return VCreatePolygon (poly->numVtces, poly->vertex, poly->color);
  486. X}
  487. *-*-END-of-./V/lib/VCopyPolygon.c-*-*
  488. echo x - ./V/lib/VDotProd.c
  489. sed 's/^X//' >./V/lib/VDotProd.c <<'*-*-END-of-./V/lib/VDotProd.c-*-*'
  490. X#include "Vlib.h"
  491. X
  492. Xdouble VDotProd (a, b)
  493. XVPoint    *a, *b; {
  494. X
  495. X    return a->x * b->x + a->y * b->y + a->z * b->z;
  496. X}
  497. *-*-END-of-./V/lib/VDotProd.c-*-*
  498. echo x - ./V/lib/VClipPolygon.c
  499. sed 's/^X//' >./V/lib/VClipPolygon.c <<'*-*-END-of-./V/lib/VClipPolygon.c-*-*'
  500. X#include "Vlib.h"
  501. X
  502. XVPolygon * _VClipPolygon (poly, clipPlane)
  503. XVPolygon *poly;
  504. XVPoint     *clipPlane; {
  505. X
  506. X    register    int j, lastj, numPts = 0, clipped = 0;
  507. X    double    d1, d2, a;
  508. X    VPoint    tmpPoint[64];
  509. X    VPolygon    *p;
  510. X
  511. X    if (poly->numVtces > 0) {
  512. X
  513. X        lastj = poly->numVtces-1;
  514. X        d1 = VDotProd(&(poly->vertex[poly->numVtces-1]), clipPlane);
  515. X        numPts = 0;
  516. X
  517. X/*
  518. X *  Examine each vertex and determine if it is inside or outside of the
  519. X *  specified clipping plane.
  520. X */
  521. X
  522. X        for (j=0; j<poly->numVtces; ++j) {
  523. X
  524. X/* Leading vertex inside? */
  525. X
  526. X        if (d1 > 0.0)
  527. X            tmpPoint[numPts++] = poly->vertex[lastj];
  528. X
  529. X        d2 = VDotProd(&(poly->vertex[j]), clipPlane);
  530. X
  531. X/* Does the edge straddle the window? If so, add a vertex on the window */
  532. X
  533. X        if (d1 * d2 < 0.0) {
  534. X            clipped = 1;
  535. X            a = d1 / (d1 - d2);
  536. X            tmpPoint[numPts].x = a * poly->vertex[j].x +
  537. X                (1.0 - a) * poly->vertex[lastj].x;
  538. X            tmpPoint[numPts].y = a * poly->vertex[j].y +
  539. X                (1.0 - a) * poly->vertex[lastj].y;
  540. X            tmpPoint[numPts++].z = a * poly->vertex[j].z +
  541. X                (1.0 - a) * poly->vertex[lastj].z;
  542. X        }
  543. X
  544. X        lastj = j;
  545. X        d1 = d2;
  546. X        }
  547. X    }
  548. X
  549. X/*
  550. X *  If the polygon was completely out of bounds, delete this polygon.
  551. X */
  552. X
  553. X    if (numPts == 0) {
  554. X    p = (VPolygon *) NULL;
  555. X    VDestroyPolygon (poly);
  556. X#ifdef DEBUG
  557. X    fprintf (stderr, "VClipPolygon: polygon outside area of interest\n");
  558. X#endif
  559. X    }
  560. X
  561. X/*
  562. X *  If we did any clipping, return the clipped polygon.
  563. X */
  564. X
  565. X    else if (clipped != 0) {
  566. X    p = VCreatePolygon(numPts, &tmpPoint[0], poly->color);
  567. X#ifdef DEBUG
  568. X    fprintf (stderr, "VClipPolygon: Polygon has been clipped:\n");
  569. X    fprintf (stderr, "Before Clipping:\n");
  570. X    VPrintPolygon (stderr, poly);
  571. X    fprintf (stderr, "\nAfter Clipping:\n\n");
  572. X    VPrintPolygon (stderr, p);
  573. X#endif
  574. X    VDestroyPolygon (poly);
  575. X    }
  576. X    else
  577. X    p = poly;
  578. X
  579. X    return p;
  580. X}
  581. X
  582. XVPolygon * VClipPolygon (poly, clipPoly)
  583. XVPolygon *poly, *clipPoly; {
  584. X
  585. X    int     i;
  586. X    VPolygon     *p = poly;
  587. X
  588. X/*
  589. X *  Clip against each clipping plane supplied, one at a time.
  590. X */
  591. X
  592. X    for (i=0; i<clipPoly->numVtces; ++i) {
  593. X
  594. X    if (p == (VPolygon *) NULL)
  595. X        break;
  596. X
  597. X    p = _VClipPolygon (p, &(clipPoly->vertex[i]));
  598. X
  599. X    }
  600. X
  601. X    return p;
  602. X}
  603. *-*-END-of-./V/lib/VClipPolygon.c-*-*
  604. echo x - ./V/lib/Imakefile
  605. sed 's/^X//' >./V/lib/Imakefile <<'*-*-END-of-./V/lib/Imakefile-*-*'
  606. XCDEBUGFLAGS = -O2
  607. XLIBOBJS    = \
  608. X      VOpenViewport.o \
  609. X      VResizeViewport.o \
  610. X      VCloseViewport.o \
  611. X      VGetEyeSpace.o \
  612. X      VGetPlanes.o \
  613. X      VReadObject.o \
  614. X      VWriteObject.o \
  615. X      VAllocColor.o \
  616. X      VBindColors.o \
  617. X      VExposeBuffer.o \
  618. X      VCreatePolygon.o \
  619. X      VCreatePoints.o \
  620. X      VCopyPolygon.o \
  621. X      VDrawPolygon.o \
  622. X      VFillPolygon.o \
  623. X      VDrawString.o \
  624. X      VClipPolygon.o \
  625. X      VDotProd.o \
  626. X      VRotate.o \
  627. X      VTransformPolygon.o \
  628. X      VTransform.o \
  629. X      VIdentMatrix.o \
  630. X      VMatrixMult.o \
  631. X      VMatrixDeterminant.o \
  632. X      VMatrixInvert.o \
  633. X      VPrintPolygon.o \
  634. X      Vmalloc.o
  635. X
  636. XNormalLibraryTarget(V,$(LIBOBJS))
  637. XInstallLibrary(V,$(USRLIBDIR))
  638. X
  639. X# DO NOT DELETE THIS LINE -- make depend depends on it.
  640. *-*-END-of-./V/lib/Imakefile-*-*
  641. echo x - ./V/lib/VGetEyeSpace.c
  642. sed 's/^X//' >./V/lib/VGetEyeSpace.c <<'*-*-END-of-./V/lib/VGetEyeSpace.c-*-*'
  643. X#include "Vlib.h"
  644. X#include <math.h>
  645. X
  646. Xvoid VGetEyeSpace (v, EyePt, CntrInt, up)
  647. XViewport *v;
  648. XVPoint    EyePt, CntrInt, up; {
  649. X
  650. X    VMatrix    Mtx, es;
  651. X    VPoint    C1, C2;
  652. X    double    Hypotenuse, h1, CosA, SinA;
  653. X
  654. X/*
  655. X *  Calculate the eye space transformation matrix
  656. X *
  657. X *  First, orient the Z axis towards the center of interest.
  658. X */
  659. X
  660. X    VIdentMatrix (&(v->eyeSpace));
  661. X    v->eyeSpace.m[0][3] = -EyePt.x;
  662. X    v->eyeSpace.m[1][3] = -EyePt.y;
  663. X    v->eyeSpace.m[2][3] = -EyePt.z;
  664. X    VTransform(&CntrInt, &(v->eyeSpace), &C1);
  665. X
  666. X    VIdentMatrix (&Mtx);
  667. X    Hypotenuse = sqrt(C1.x * C1.x + C1.y * C1.y);
  668. X    if (Hypotenuse > 0.0) {
  669. X        CosA = C1.y / Hypotenuse;
  670. X        SinA = C1.x / Hypotenuse;
  671. X        Mtx.m[0][0] = CosA;
  672. X        Mtx.m[1][0] = SinA;
  673. X        Mtx.m[0][1] = -SinA;
  674. X        Mtx.m[1][1] = CosA;
  675. X        es = v->eyeSpace;
  676. X        VMatrixMult(&es, &Mtx, &(v->eyeSpace));
  677. X    }
  678. X
  679. X    VTransform(&CntrInt, &(v->eyeSpace), &C2);
  680. X    VIdentMatrix (&Mtx);
  681. X    Hypotenuse = sqrt(C2.y * C2.y + C2.z * C2.z);
  682. X    if (Hypotenuse > 0.0) {
  683. X        CosA = C2.y / Hypotenuse;
  684. X        SinA = -C2.z / Hypotenuse;
  685. X        Mtx.m[1][1] = CosA;
  686. X        Mtx.m[2][1] = SinA;
  687. X        Mtx.m[1][2] = -SinA;
  688. X        Mtx.m[2][2] = CosA;
  689. X        es = v->eyeSpace;
  690. X        VMatrixMult(&es, &Mtx, &(v->eyeSpace));
  691. X    }
  692. X
  693. X/*
  694. X *  Orient the y axis towards "up". Swap y and z axes.
  695. X */
  696. X
  697. X    VTransform (&up, &(v->eyeSpace), &C2);
  698. X    VIdentMatrix (&Mtx);
  699. X    h1 = sqrt (C2.y * C2.y + C2.z * C2.z);
  700. X    Hypotenuse = sqrt(C2.x * C2.x + h1 * h1);
  701. X    if (Hypotenuse > 0.0) {
  702. X        CosA = h1 / Hypotenuse;
  703. X        SinA = C2.x / Hypotenuse;
  704. X        if (C2.z < 0.0) {
  705. X            CosA = -CosA;
  706. X        }
  707. X        Mtx.m[0][0] = CosA;
  708. X        Mtx.m[2][0] = SinA;
  709. X        Mtx.m[0][2] = -SinA;
  710. X        Mtx.m[2][2] = CosA;
  711. X        es = v->eyeSpace;
  712. X        VMatrixMult(&es, &Mtx, &(v->eyeSpace));
  713. X    }
  714. X
  715. X    VIdentMatrix (&Mtx);
  716. X    Mtx.m[1][1] = 0.0;
  717. X    Mtx.m[2][1] = 1.0;
  718. X    Mtx.m[1][2] = 1.0;
  719. X    Mtx.m[2][2] = 0.0;
  720. X    es = v->eyeSpace;
  721. X    VMatrixMult(&es, &Mtx, &(v->eyeSpace));
  722. X
  723. X}
  724. *-*-END-of-./V/lib/VGetEyeSpace.c-*-*
  725. echo x - ./V/lib/VDrawPolygon.c
  726. sed 's/^X//' >./V/lib/VDrawPolygon.c <<'*-*-END-of-./V/lib/VDrawPolygon.c-*-*'
  727. X#include "Vlib.h"
  728. X
  729. Xvoid VDrawPolygon(v, win, gc, poly)
  730. XViewport *v;
  731. XWindow     *win;
  732. XGC     gc;
  733. XVPolygon *poly; {
  734. X
  735. X    VPoint     TmpPt, *p;
  736. X    XPoint    xpt[VmaxVP];
  737. X    int    i;
  738. X    Drawable d;
  739. X
  740. X    d = (v->flags & VPMono) ? (Drawable) v->monoPixmap : (Drawable) win;
  741. X
  742. X    if (poly == (VPolygon *) NULL)
  743. X        return;
  744. X
  745. X    for ((i=0, p=poly->vertex); i<poly->numVtces; (++i, ++p)) {
  746. X        if (v->flags & VPPerspective) {
  747. X        TmpPt.x = v->Middl.x + v->Scale.x * p->x / p->z;
  748. X        TmpPt.y = v->Middl.y - v->Scale.y * p->y / p->z;
  749. X        }
  750. X        else {
  751. X        TmpPt.x = v->Middl.x + v->Scale.x * p->x;
  752. X        TmpPt.y = v->Middl.y - v->Scale.y * p->y;
  753. X        }
  754. X        xpt[i].x = TmpPt.x + 0.5;
  755. X        xpt[i].y = TmpPt.y + 0.5;
  756. X    }
  757. X
  758. X    if (i > 0) {
  759. X        xpt[i] = xpt[0];
  760. X        XDrawLines (v->dpy, d, gc, xpt, i+1, CoordModeOrigin);
  761. X    }
  762. X
  763. X}
  764. *-*-END-of-./V/lib/VDrawPolygon.c-*-*
  765. echo x - ./V/lib/Vmalloc.c
  766. sed 's/^X//' >./V/lib/Vmalloc.c <<'*-*-END-of-./V/lib/Vmalloc.c-*-*'
  767. X#include "Vlib.h"
  768. X
  769. Xextern char * malloc();
  770. X
  771. Xchar *Vmalloc(size)
  772. Xint    size; {
  773. X
  774. X    char    *p;
  775. X
  776. X    if ((p = malloc(size)) == (char *) NULL) {
  777. X        fprintf (stderr, "V package memory allocation error.\n");
  778. X        fprintf (stderr, "An error was encountered allocating\
  779. X %d bytes.\n", size);
  780. X        exit (1);
  781. X    }
  782. X    return p;
  783. X}
  784. *-*-END-of-./V/lib/Vmalloc.c-*-*
  785. echo x - ./V/lib/VReadObject.c
  786. sed 's/^X//' >./V/lib/VReadObject.c <<'*-*-END-of-./V/lib/VReadObject.c-*-*'
  787. X#include "Vlib.h"
  788. X#include <string.h>
  789. X
  790. XVObject *VReadObject(f)
  791. XFILE *f; {
  792. X
  793. X    short    I, J, vertex, vertices, NumPts, NumPolys;
  794. X    float    x, y, z;
  795. X    char    str[64], name[128];
  796. X    VPoint    *tmpPts, pts[VmaxVP];
  797. X    VPolygon **polygons;
  798. X    VObject    *object;
  799. X
  800. X    fscanf(f, "%s\n", name);
  801. X    fscanf(f, "%hd", &NumPts);
  802. X    fscanf(f, "%hd", &NumPolys);
  803. X
  804. X    tmpPts = (VPoint *) Vmalloc (NumPts * sizeof(VPoint));
  805. X    polygons = (VPolygon **) Vmalloc (NumPolys * sizeof(VPolygon *));
  806. X
  807. X    for (I=0; I<NumPts; ++I) {
  808. X        fscanf(f, "%hd", &J);
  809. X        fscanf(f, "%f", &x);
  810. X        fscanf(f, "%f", &y);
  811. X        fscanf(f, "%f", &z);
  812. X        tmpPts[I].x = x;
  813. X        tmpPts[I].y = y;
  814. X        tmpPts[I].z = z;
  815. X    }
  816. X
  817. X    for (I=0; I<NumPolys; ++I) {
  818. X        fscanf(f, "%s %hd", str, &(vertices));
  819. X        for (J=0; J<vertices; ++J) {
  820. X            fscanf(f, "%hd", &(vertex));
  821. X            pts[J] = tmpPts[vertex - 1];
  822. X        }
  823. X        polygons[I] = VCreatePolygon (vertices, pts, VAllocColor(str));
  824. X    }
  825. X
  826. X    object = (VObject *) Vmalloc (sizeof(VObject));
  827. X    object->name = strdup (name);
  828. X    object->numPolys = NumPolys;
  829. X    object->polygon = polygons;
  830. X
  831. X    free ((char *) tmpPts);
  832. X    return ferror(f) ? (VObject *) 0 : object;
  833. X}
  834. *-*-END-of-./V/lib/VReadObject.c-*-*
  835. echo x - ./V/lib/VMatrixMult.c
  836. sed 's/^X//' >./V/lib/VMatrixMult.c <<'*-*-END-of-./V/lib/VMatrixMult.c-*-*'
  837. X#include "Vlib.h"
  838. X
  839. Xvoid VMatrixMult (Mt1, Mt2, R)
  840. XVMatrix *Mt1, *Mt2, *R; {
  841. X    short I, J, K;
  842. X
  843. X    for (I=0; I<4; ++I)
  844. X        for (J=0; J<4; ++J) {
  845. X            R->m[I][J] = 0.0;
  846. X            for (K=0; K<4; ++K)
  847. X                R->m[I][J] = R->m[I][J] + Mt1->m[K][J] * Mt2->m[I][K];
  848. X        }
  849. X}
  850. *-*-END-of-./V/lib/VMatrixMult.c-*-*
  851. echo x - ./V/lib/VTransform.c
  852. sed 's/^X//' >./V/lib/VTransform.c <<'*-*-END-of-./V/lib/VTransform.c-*-*'
  853. X#include "Vlib.h"
  854. X
  855. X/*
  856. X * VTransform: transform a point from one coordinate system to another.
  857. X */
  858. X
  859. Xvoid VTransform (pt, mt, newPt)
  860. XVPoint    *pt;
  861. XVMatrix *mt;
  862. XVPoint    *newPt; {
  863. X
  864. X  newPt->x = pt->x * mt->m[0][0] + pt->y * mt->m[0][1]
  865. X        + pt->z * mt->m[0][2] + mt->m[0][3];
  866. X
  867. X  newPt->y = pt->x * mt->m[1][0] + pt->y * mt->m[1][1]
  868. X          + pt->z * mt->m[1][2] + mt->m[1][3];
  869. X
  870. X  newPt->z = pt->x * mt->m[2][0] + pt->y * mt->m[2][1]
  871. X          + pt->z * mt->m[2][2] + mt->m[2][3];
  872. X}
  873. *-*-END-of-./V/lib/VTransform.c-*-*
  874. echo x - ./V/lib/VIdentMatrix.c
  875. sed 's/^X//' >./V/lib/VIdentMatrix.c <<'*-*-END-of-./V/lib/VIdentMatrix.c-*-*'
  876. X#include "Vlib.h"
  877. X
  878. Xvoid VIdentMatrix (Mtx)
  879. XVMatrix *Mtx;
  880. X{
  881. X    short I, J;
  882. X
  883. X    for (I=0; I<4; ++I)
  884. X        for (J=0; J<4; ++J)
  885. X            if (I == J)
  886. X                (*Mtx).m[I][J] = 1.0;
  887. X            else
  888. X                (*Mtx).m[I][J] = 0.0;
  889. X
  890. X}
  891. *-*-END-of-./V/lib/VIdentMatrix.c-*-*
  892. echo x - ./V/lib/VDisplayObjects.c
  893. sed 's/^X//' >./V/lib/VDisplayObjects.c <<'*-*-END-of-./V/lib/VDisplayObjects.c-*-*'
  894. X#include "Vlib.h"
  895. X
  896. Xvoid VDisplayObjects() {
  897. X
  898. X    Point3     TmpPt;
  899. X    int    I, J;
  900. X    XPoint    xpt[MaxPts];
  901. X
  902. X    for (I=0; I<NumPolys; ++I) {
  903. X
  904. X        for (J=0; J<Polygons[I].PolyVtces; ++J) {
  905. X            Transform(&Points[Vertices[Polygons[I].Start + J]], &EyeSpace, &TmpPt);
  906. X            MakeDisplayable(&TmpPt);
  907. X            xpt[J].x = (int) TmpPt.X;
  908. X            xpt[J].y = (int) TmpPt.Y;
  909. X        }
  910. X/*        xpt[J] = xpt[0];
  911. X        XDrawLines (dpy, win, gc, &xpt, J+1, CoordModeOrigin); */
  912. X        XFillPolygon (dpy, win, curGC, &xpt, J, Nonconvex, CoordModeOrigin);
  913. X    }
  914. X
  915. X}
  916. *-*-END-of-./V/lib/VDisplayObjects.c-*-*
  917. echo x - ./V/lib/VRotate.c
  918. sed 's/^X//' >./V/lib/VRotate.c <<'*-*-END-of-./V/lib/VRotate.c-*-*'
  919. X#include "Vlib.h"
  920. X#include <math.h>
  921. X
  922. XVMatrix *VRotate (Mt1, operation, angle)
  923. XVMatrix * Mt1;
  924. Xint    operation;
  925. Xdouble    angle; {
  926. X
  927. X    VMatrix    m, s;
  928. X
  929. X    VIdentMatrix (&m);
  930. X
  931. X    switch (operation) {
  932. X    case XRotation:
  933. X        m.m[1][1] = m.m[2][2] = cos(angle);
  934. X        m.m[2][1] = sin(angle);
  935. X        m.m[1][2] = - m.m[2][1];
  936. X        break;
  937. X    case YRotation: 
  938. X        m.m[0][0] = m.m[2][2] = cos(angle);
  939. X        m.m[2][0] = sin(angle);
  940. X        m.m[0][2] = - m.m[2][0];
  941. X        break;
  942. X    case ZRotation:
  943. X        m.m[0][0] = m.m[1][1] = cos(angle);
  944. X        m.m[1][0] = sin(angle);
  945. X        m.m[0][1] = - m.m[1][0];
  946. X        break;
  947. X    }
  948. X
  949. X    s = *Mt1;
  950. X
  951. X    VMatrixMult (&s, &m, Mt1);
  952. X    return Mt1;
  953. X}
  954. X
  955. XVMatrix *VTranslatePoint (Mt, loc)
  956. XVMatrix *Mt;
  957. XVPoint  loc; {
  958. X
  959. X    Mt->m[0][3] = Mt->m[0][3] + loc.x;
  960. X    Mt->m[1][3] = Mt->m[1][3] + loc.y;
  961. X    Mt->m[2][3] = Mt->m[2][3] + loc.z;
  962. X    return Mt;
  963. X
  964. X}
  965. X
  966. XVMatrix *VTranslate (Mt, x, y ,z)
  967. XVMatrix *Mt;
  968. Xdouble  x, y, z; {
  969. X
  970. X    Mt->m[0][3] = Mt->m[0][3] + x;
  971. X    Mt->m[1][3] = Mt->m[1][3] + y;
  972. X    Mt->m[2][3] = Mt->m[2][3] + z;
  973. X    return Mt;
  974. X}
  975. *-*-END-of-./V/lib/VRotate.c-*-*
  976. echo x - ./V/lib/VGetPlanes.c
  977. sed 's/^X//' >./V/lib/VGetPlanes.c <<'*-*-END-of-./V/lib/VGetPlanes.c-*-*'
  978. X#include "Vlib.h"
  979. X
  980. XVPolygon *VGetPlanes (poly)
  981. XVPolygon *poly; {
  982. X
  983. X    VPoint    tmp[64], *p;
  984. X    int    i, lasti;
  985. X
  986. X    lasti = poly->numVtces - 1;
  987. X    p = poly->vertex;
  988. X
  989. X    for (i=0; i<poly->numVtces; ++i) {
  990. X        tmp[i].x = p->y * poly->vertex[lasti].z - p->z *
  991. X        poly->vertex[lasti].y;
  992. X        tmp[i].y = p->z * poly->vertex[lasti].x - p->x *
  993. X        poly->vertex[lasti].z;
  994. X        tmp[i].z = p->x * poly->vertex[lasti].y - p->y *
  995. X        poly->vertex[lasti].x;
  996. X        lasti = i;
  997. X        p++;
  998. X    }
  999. X
  1000. X    for (i=0; i<poly->numVtces; ++i)
  1001. X        poly->vertex[i] = tmp[i];
  1002. X
  1003. X    return poly;
  1004. X}
  1005. *-*-END-of-./V/lib/VGetPlanes.c-*-*
  1006. echo x - ./V/lib/VOpenViewport.c
  1007. sed 's/^X//' >./V/lib/VOpenViewport.c <<'*-*-END-of-./V/lib/VOpenViewport.c-*-*'
  1008. X#include "Vlib.h"
  1009. X
  1010. XViewport *VOpenViewport (dpy, screen, win, unit, dist, scale, width, height)
  1011. XDisplay    *dpy;
  1012. Xint    screen;
  1013. XWindow    *win;
  1014. Xdouble  unit;
  1015. Xdouble  dist;
  1016. Xdouble  scale;
  1017. Xint    width;
  1018. Xint    height; {
  1019. X
  1020. X    Viewport *v;
  1021. X    VPoint     clip[4];
  1022. X
  1023. X/*
  1024. X *  Allocate space for the Viewport structure
  1025. X */
  1026. X
  1027. X    v = (Viewport *) Vmalloc (sizeof(Viewport));
  1028. X
  1029. X/*
  1030. X * Calculate screen resolution in pixels per unit.
  1031. X */
  1032. X
  1033. X    v->dist = dist;
  1034. X    v->units = unit;
  1035. X
  1036. X        v->xres = ((((double) DisplayWidth(dpy,screen)) * unit * 1000.0) /
  1037. X            ((double) DisplayWidthMM(dpy,screen)));
  1038. X        v->yres = ((((double) DisplayHeight(dpy,screen)) * unit * 1000.0) /
  1039. X            ((double) DisplayHeightMM(dpy,screen)));
  1040. X/*
  1041. X *  Use that info to set scaling factors.
  1042. X */
  1043. X
  1044. X        v->Scale.x = v->xres * dist * scale;
  1045. X        v->Scale.y = v->yres * dist * scale;
  1046. X        v->Scale.z = 1.0;
  1047. X
  1048. X        v->Middl.x = (double) width / 2.0;
  1049. X        v->Middl.y = (double) height / 2.0;
  1050. X        v->Middl.z = 0.0;
  1051. X
  1052. X/*
  1053. X *  Build the clipping planes for our view into the eye space.
  1054. X */
  1055. X
  1056. X        clip[0].x = - width / v->xres / 2.0 / scale;
  1057. X        clip[0].y = - height / v->yres / 2.0 / scale;
  1058. X        clip[0].z = dist;
  1059. X        clip[1].x = - width / v->xres / 2.0 / scale;
  1060. X        clip[1].y = height / v->yres / 2.0 / scale;
  1061. X        clip[1].z = dist;
  1062. X        clip[2].x = width / v->xres / 2.0 / scale;
  1063. X        clip[2].y = height / v->yres / 2.0 / scale;
  1064. X        clip[2].z = dist;
  1065. X        clip[3].x = width / v->xres / 2.0 / scale;
  1066. X        clip[3].y = - height / v->yres / 2.0 / scale;
  1067. X        clip[3].z = dist;
  1068. X
  1069. X        v->clipPoly = VCreatePolygon (4, clip);
  1070. X        VGetPlanes (v->clipPoly);
  1071. X
  1072. X/*
  1073. X *  Fill out the rest of the structure.
  1074. X */
  1075. X
  1076. X    v->flags = VPPerspective | VPClip;
  1077. X    v->dpy = dpy;
  1078. X    v->screen = screen;
  1079. X    v->win = win;
  1080. X    VIdentMatrix (&v->eyeSpace);
  1081. X    v->set = 0;
  1082. X
  1083. X/*
  1084. X *  Is this a monochrome situation?
  1085. X */
  1086. X
  1087. X    if (DisplayPlanes (dpy, screen) < 2) {
  1088. X        v->monoPixmap = XCreatePixmap (dpy, RootWindow(dpy, screen), width, height, 1);
  1089. X        v->flags |= VPMono;
  1090. X    }
  1091. X
  1092. X    return v;
  1093. X}
  1094. *-*-END-of-./V/lib/VOpenViewport.c-*-*
  1095. echo x - ./V/lib/VDrawString.c
  1096. sed 's/^X//' >./V/lib/VDrawString.c <<'*-*-END-of-./V/lib/VDrawString.c-*-*'
  1097. X#include "Vlib.h"
  1098. X
  1099. Xvoid VDrawString(v, win, gc, p, str, len)
  1100. XViewport *v;
  1101. XWindow     *win;
  1102. XGC     gc;
  1103. XVPoint     *p;
  1104. Xchar     *str;
  1105. Xint     len; {
  1106. X
  1107. X    VPoint     TmpPt;
  1108. X    register int    x, y;
  1109. X
  1110. X    if (v->flags & VPPerspective) {
  1111. X        TmpPt.x = v->Middl.x + v->Scale.x * p->x / p->z;
  1112. X        TmpPt.y = v->Middl.y - v->Scale.y * p->y / p->z;
  1113. X    }
  1114. X    else {
  1115. X        TmpPt.x = v->Middl.x + v->Scale.x * p->x;
  1116. X        TmpPt.y = v->Middl.y - v->Scale.y * p->y;
  1117. X    }
  1118. X
  1119. X    x = TmpPt.x + 0.5;
  1120. X    y = TmpPt.y + 0.5;
  1121. X
  1122. X    XDrawString (v->dpy, win, gc, x, y, str, len);
  1123. X
  1124. X}
  1125. *-*-END-of-./V/lib/VDrawString.c-*-*
  1126. echo x - ./V/lib/VTransformPolygon.c
  1127. sed 's/^X//' >./V/lib/VTransformPolygon.c <<'*-*-END-of-./V/lib/VTransformPolygon.c-*-*'
  1128. X#include "Vlib.h"
  1129. X
  1130. XVPolygon *VTransformPolygon (poly, m)
  1131. XVPolygon *poly;
  1132. XVMatrix *m; {
  1133. X
  1134. X    int    i;
  1135. X    VPoint    tmp;
  1136. X
  1137. X    for (i=0; i<poly->numVtces; ++i) {
  1138. X        VTransform (&(poly->vertex[i]), m, &tmp);
  1139. X        poly->vertex[i] = tmp;
  1140. X    }
  1141. X
  1142. X    return poly;
  1143. X}
  1144. *-*-END-of-./V/lib/VTransformPolygon.c-*-*
  1145. echo x - ./V/lib/VCloseViewport.c
  1146. sed 's/^X//' >./V/lib/VCloseViewport.c <<'*-*-END-of-./V/lib/VCloseViewport.c-*-*'
  1147. X#include "Vlib.h"
  1148. X
  1149. Xvoid VCloseViewport (v)
  1150. XViewport *v; {
  1151. X
  1152. X    VDestroyPolygon (v->clipPoly);
  1153. X    free ((char *) v);
  1154. X}
  1155. *-*-END-of-./V/lib/VCloseViewport.c-*-*
  1156. echo x - ./V/lib/VWriteObject.c
  1157. sed 's/^X//' >./V/lib/VWriteObject.c <<'*-*-END-of-./V/lib/VWriteObject.c-*-*'
  1158. X#include "Vlib.h"
  1159. X#include <string.h>
  1160. X
  1161. Xint VWriteObject(f, obj)
  1162. XFILE    *f;
  1163. XVObject *obj; {
  1164. X
  1165. X    int     i, j, k, points;
  1166. X    VPolygon **q;
  1167. X    VPoint     *p;
  1168. X
  1169. X/*
  1170. X *  Total the number of vertices in all of the object's polygons
  1171. X */
  1172. X
  1173. X    points = 0;
  1174. X    q = obj->polygon;
  1175. X    for (i=0; i<obj->numPolys; ++i) {
  1176. X        points += q[i]->numVtces;
  1177. X    }
  1178. X
  1179. X/*
  1180. X *  Print the header
  1181. X */
  1182. X
  1183. X    fprintf (f, "%s\n%d %d\n", obj->name, points, obj->numPolys);
  1184. X
  1185. X/*
  1186. X *  Print the point list
  1187. X */
  1188. X
  1189. X    k = 1;
  1190. X    q = obj->polygon;
  1191. X    for (i=0; i<obj->numPolys; ++i) {
  1192. X        for ((j=0, p=q[i]->vertex); j<q[i]->numVtces; (++p, ++j)) {
  1193. X            fprintf(f, "%d %g %g %g\n", k, p->x, p->y, p->z);
  1194. X            ++k;
  1195. X        }
  1196. X    }
  1197. X
  1198. X/*
  1199. X *  Print the polygon list
  1200. X */
  1201. X
  1202. X    k = 1;
  1203. X    q = obj->polygon;
  1204. X    for (i=0; i<obj->numPolys; ++i) {
  1205. X        fprintf(f, "%s %d", q[i]->color->color_name, q[i]->numVtces);
  1206. X        for (j=0; j<q[i]->numVtces; ++j)
  1207. X            fprintf(f, " %d", k++);
  1208. X        fprintf (f, "\n");
  1209. X    }
  1210. X
  1211. X    return ferror(f) ? -1 : 0;
  1212. X}
  1213. *-*-END-of-./V/lib/VWriteObject.c-*-*
  1214. echo x - ./V/lib/VFillPolygon.c
  1215. sed 's/^X//' >./V/lib/VFillPolygon.c <<'*-*-END-of-./V/lib/VFillPolygon.c-*-*'
  1216. X#include "Vlib.h"
  1217. X
  1218. X#define COLLAPSEUNUSEDPOINTS
  1219. X
  1220. Xvoid VFillPolygon(v, win, gc, poly)
  1221. XViewport *v;
  1222. XWindow     *win;
  1223. XGC     gc;
  1224. XVPolygon *poly; {
  1225. X
  1226. X    VPoint     TmpPt, *p;
  1227. X    XPoint    xpt[VmaxVP], *lastpt;
  1228. X    int    i, k;
  1229. X    Drawable d;
  1230. X
  1231. X    d = (v->flags & VPMono) ? (Drawable) v->monoPixmap : (Drawable) win;
  1232. X
  1233. X    if (poly == (VPolygon *) NULL)
  1234. X        return;
  1235. X
  1236. X    k = 0;
  1237. X    lastpt = &xpt[0];
  1238. X    for ((i=0, p=poly->vertex); i<poly->numVtces; (++i, ++p)) {
  1239. X        if (v->flags & VPPerspective) {
  1240. X        TmpPt.x = v->Middl.x + v->Scale.x * p->x / p->z;
  1241. X        TmpPt.y = v->Middl.y - v->Scale.y * p->y / p->z;
  1242. X        }
  1243. X        else {
  1244. X        TmpPt.x = v->Middl.x + v->Scale.x * p->x;
  1245. X        TmpPt.y = v->Middl.y - v->Scale.y * p->y;
  1246. X        }
  1247. X
  1248. X#ifdef COLLAPSEUNUSEDPOINTS
  1249. X        xpt[k].x = TmpPt.x + 0.5;
  1250. X        xpt[k].y = TmpPt.y + 0.5;
  1251. X
  1252. X        if (k == 0 || !(xpt[k].x == lastpt->x && xpt[k].y == lastpt->y))
  1253. X        lastpt = &xpt[k++];
  1254. X
  1255. X#else
  1256. X        xpt[k].x = TmpPt.x + 0.5;
  1257. X        xpt[k].y = TmpPt.y + 0.5;
  1258. X        ++k;
  1259. X#endif
  1260. X
  1261. X    }
  1262. X
  1263. X    if (k > 0) {
  1264. X#ifdef COLLAPSEUNUSEDPOINTS
  1265. X        if (k == 1)
  1266. X            XDrawPoint (v->dpy, d, gc, xpt[0].x, xpt[0].y);
  1267. X        else if (k == 2)
  1268. X            XDrawLines (v->dpy, d, gc, xpt, 2, CoordModeOrigin);
  1269. X        else
  1270. X#endif
  1271. X        XFillPolygon (v->dpy, d, gc, xpt, k, Nonconvex, CoordModeOrigin);
  1272. X    }
  1273. X
  1274. X}
  1275. *-*-END-of-./V/lib/VFillPolygon.c-*-*
  1276. echo x - ./V/lib/VMatrixInvert.c
  1277. sed 's/^X//' >./V/lib/VMatrixInvert.c <<'*-*-END-of-./V/lib/VMatrixInvert.c-*-*'
  1278. X#include "Vlib.h"
  1279. X
  1280. X#define mod(a)    (a < 0 ? a + 3 : a % 3)
  1281. X
  1282. XVMatrix *VMatrixInvert(s, d)
  1283. XVMatrix *s;
  1284. XVMatrix *d; {
  1285. X
  1286. X    register int    i, j;
  1287. X    register double det;
  1288. X
  1289. X    det = VMatrixDeterminant (s);
  1290. X
  1291. X    for (i=0; i<4; ++i)
  1292. X        for (j=0; j<4; ++j)
  1293. X            d->m[j][i] =(s->m[mod(j+1)][mod(i+1)] *
  1294. X                     s->m[mod(j+2)][mod(i+2)] -
  1295. X                     s->m[mod(j-1)][mod(i+1)] *
  1296. X                     s->m[mod(j-2)][mod(i+2)] ) / det;
  1297. X
  1298. X    return d;
  1299. X}
  1300. *-*-END-of-./V/lib/VMatrixInvert.c-*-*
  1301. echo x - ./V/lib/VMatrixDeterminant.c
  1302. sed 's/^X//' >./V/lib/VMatrixDeterminant.c <<'*-*-END-of-./V/lib/VMatrixDeterminant.c-*-*'
  1303. X#include "Vlib.h"
  1304. X
  1305. Xdouble VMatrixDeterminant(m)
  1306. XVMatrix *m; {
  1307. X
  1308. X    double    det;
  1309. X
  1310. X    det = m->m[0][0] * m->m[1][1] * m->m[2][2] * m->m[3][3] +
  1311. X          m->m[1][0] * m->m[2][1] * m->m[3][2] * m->m[0][3] +
  1312. X          m->m[2][0] * m->m[3][1] * m->m[0][2] * m->m[1][3] +
  1313. X          m->m[3][0] * m->m[0][1] * m->m[1][2] * m->m[2][3] -
  1314. X          m->m[0][3] * m->m[1][2] * m->m[2][1] * m->m[3][0] -
  1315. X          m->m[1][3] * m->m[2][2] * m->m[3][1] * m->m[0][0] -
  1316. X          m->m[2][3] * m->m[3][2] * m->m[0][1] * m->m[1][0] -
  1317. X          m->m[3][3] * m->m[0][2] * m->m[1][1] * m->m[2][0];
  1318. X
  1319. X    return det;
  1320. X}
  1321. *-*-END-of-./V/lib/VMatrixDeterminant.c-*-*
  1322. echo x - ./V/lib/VBindColors.c
  1323. sed 's/^X//' >./V/lib/VBindColors.c <<'*-*-END-of-./V/lib/VBindColors.c-*-*'
  1324. X#include "Vlib.h"
  1325. X#include <math.h>
  1326. X
  1327. Xint    pmap (vec, n)
  1328. Xint    *vec;
  1329. Xint    n; {
  1330. X
  1331. X    static int itbl[] = {1, 2, 4, 8};
  1332. X    register int i, r=0;
  1333. X
  1334. X    for (i=0; i<4; ++i)
  1335. X    if (itbl[i] & n)
  1336. X       r += vec[i];
  1337. X    return r;
  1338. X}
  1339. X
  1340. Xint VBindColors (v, background)
  1341. XViewport *v;
  1342. Xchar * background; {
  1343. X
  1344. X    register int i, j, k, n, c;
  1345. X    static   int parseComplete = 0;
  1346. X    unsigned int pixel;
  1347. X    VColor     *p;
  1348. X    Display    *dpy;
  1349. X    XColor    colorSet[MAXCOLORS];
  1350. X    unsigned long planemask[PLANES*2];
  1351. X    unsigned long pixels[1];
  1352. X
  1353. X
  1354. X    if (v->flags & VPMono)
  1355. X    return 0;
  1356. X
  1357. X    n = PLANES;
  1358. X    c = (int) (pow(2.0, (double) n) + 0.01);
  1359. X    dpy = v->dpy;
  1360. X
  1361. X    v->cmap = DefaultColormap(dpy, DefaultScreen(dpy));
  1362. X
  1363. X    if (XAllocColorCells (dpy, v->cmap, False, planemask, n*2, pixels, 1) == 0) {
  1364. X        fprintf (stderr, "Cannot allocate color cells\n");
  1365. X        return -1;
  1366. X    }
  1367. X
  1368. X/*
  1369. X *  Parse background color
  1370. X */
  1371. X
  1372. X    if (/*parseComplete == 0*/ 1) {
  1373. X
  1374. X    if (XParseColor(dpy, v->cmap, background, &colorSet[0]) == 0) {
  1375. X        fprintf (stderr, "Can't parse color %s\n", background);
  1376. X            return -1;
  1377. X        }
  1378. X
  1379. X/*
  1380. X *  Parse each color defined in the V Color List
  1381. X */
  1382. X
  1383. X    for ((i=0, p=VColorList); p != (VColor *) 0; i++) {
  1384. X        if (i > c) {
  1385. X            fprintf (stderr, "Too many colors selected.\n");
  1386. X            return -1;
  1387. X        }
  1388. X        if (XParseColor (dpy, v->cmap, p->color_name, &colorSet[i+1]) == 0) {
  1389. X            fprintf (stderr, "Can't parse color %s\n", p->color_name);
  1390. X            return -1;
  1391. X        }
  1392. X        p->xcolor = colorSet[i+1];
  1393. X        p->index = i+1;
  1394. X        p = p->next;
  1395. X    }
  1396. X
  1397. X    parseComplete = 1;
  1398. X    }
  1399. X
  1400. X    v->colors = i+1;
  1401. X
  1402. X#ifdef DEBUG
  1403. X    fprintf (stderr, "%d colors defined in the V color list.\n", i);
  1404. X#endif
  1405. X
  1406. X/*
  1407. X *  PAY ATTENTION!
  1408. X *
  1409. X *  We will now create a two lists of XColors. Each will expose a particular
  1410. X *  drawing buffer (there are two drawing buffers created here).
  1411. X *  A drawing is exposed by passing one of these lists to the XSetColors
  1412. X *  procedure.
  1413. X *  We create a list by iterating through each possible combination of
  1414. X *  pixel values, based on the values returned in pixel and planemask.
  1415. X *  The pixel value is determined using a function called pmap.  Each pixel
  1416. X *  value is assigned the appropriate XColor.
  1417. X */
  1418. X
  1419. X    k = 0;
  1420. X    for (i=0; i<v->colors; ++i) {
  1421. X    pixel = v->aPixel[i] = pmap(&planemask[0], i) | pixels[0];
  1422. X    for (j=0; j<v->colors; ++j) {
  1423. X        v->aColor[k] = colorSet[i];
  1424. X        v->aColor[k++].pixel = pixel | pmap (&planemask[n], j);
  1425. X    }
  1426. X    }
  1427. X
  1428. X    v->aMask = pmap(&planemask[0], (c-1)) | pixels[0];
  1429. X
  1430. X    k = 0;
  1431. X    for (i=0; i<v->colors; ++i) {
  1432. X    pixel = v->bPixel[i] = pmap(&planemask[n], i) | pixels[0];
  1433. X    for (j=0; j<v->colors; ++j) {
  1434. X        v->bColor[k] = colorSet[i];
  1435. X        v->bColor[k++].pixel = pixel | pmap(&planemask[0], j);
  1436. X    }
  1437. X    }
  1438. X
  1439. X    v->bMask = pmap(&planemask[n], (c-1)) | pixels[0];
  1440. X
  1441. X    return 0;
  1442. X}
  1443. *-*-END-of-./V/lib/VBindColors.c-*-*
  1444. echo x - ./V/lib/VExposeBuffer.c
  1445. sed 's/^X//' >./V/lib/VExposeBuffer.c <<'*-*-END-of-./V/lib/VExposeBuffer.c-*-*'
  1446. X#include "Vlib.h"
  1447. X
  1448. Xvoid VExposeBuffer (v, gc)
  1449. XViewport *v;
  1450. XGC    gc; {
  1451. X
  1452. X    VColor *p;
  1453. X    unsigned long *q;
  1454. X
  1455. X/*
  1456. X * this is one area where more-than-one window per display gets hairy -- this call
  1457. X * really exposes the drawings buffered in all windows associated with a given display.
  1458. X * the calling sequence needs to be changed to reflect this.
  1459. X */
  1460. X
  1461. X    if (v->flags & VPMono) {
  1462. X    XCopyArea (v->dpy, v->monoPixmap, v->win, gc,
  1463. X        0, 0, v->width, v->height, 0, 0);
  1464. X    XSetForeground (v->dpy, gc, WhitePixel(v->dpy, v->screen));
  1465. X    XFillRectangle (v->dpy, v->monoPixmap, gc, 0, 0, v->width, v->height);
  1466. X    XSetForeground (v->dpy, gc, BlackPixel(v->dpy, v->screen));
  1467. X    return;
  1468. X    }
  1469. X
  1470. X    if (v->set == 0) {
  1471. X    v->set = 1;
  1472. X    XStoreColors (v->dpy, v->cmap, v->aColor, v->colors*v->colors);
  1473. X    v->pixel = &(v->bPixel[0]);
  1474. X    XSetPlaneMask (v->dpy, gc, v->bMask);
  1475. X    v->mask = v->bMask;
  1476. X    /*
  1477. X    for ((p=VColorList, q = &(v->bPixel[1])); p != (VColor *) 0; ++q) {
  1478. X        p->xcolor.pixel = *q;
  1479. X        p = p->next;
  1480. X    }
  1481. X    */
  1482. X    }
  1483. X    else {
  1484. X    v->set = 0;
  1485. X    XStoreColors (v->dpy, v->cmap, v->bColor, v->colors*v->colors);
  1486. X    v->pixel = &(v->aPixel[0]);
  1487. X    XSetPlaneMask (v->dpy, gc, v->aMask);
  1488. X    v->mask = v->aMask;
  1489. X    /*
  1490. X    for ((p=VColorList, q = &(v->aPixel[1])); p != (VColor *) 0; ++q) {
  1491. X        p->xcolor.pixel = *q;
  1492. X        p = p->next;
  1493. X    }
  1494. X    */
  1495. X    }
  1496. X
  1497. X/*    XSync (v->dpy, False); */
  1498. X    XFlush (v->dpy);
  1499. X}
  1500. *-*-END-of-./V/lib/VExposeBuffer.c-*-*
  1501. echo x - ./V/lib/VAllocColor.c
  1502. sed 's/^X//' >./V/lib/VAllocColor.c <<'*-*-END-of-./V/lib/VAllocColor.c-*-*'
  1503. X#include "Vlib.h"
  1504. X#include <string.h>
  1505. X
  1506. XVColor *VAllocColor (name)
  1507. Xchar *name; {
  1508. X
  1509. X    VColor    *p=VColorList, *prev=0, **q;
  1510. X
  1511. X/*
  1512. X *  Search for this color among those already allocated.
  1513. X */
  1514. X
  1515. X    while (p != (VColor *) 0) {
  1516. X        if (strcmp(p->color_name, name) == 0) {
  1517. X            return p;
  1518. X        }
  1519. X        prev = p;
  1520. X        p = p->next;
  1521. X    }
  1522. X
  1523. X/*
  1524. X *  The color was not in the list; allocate a new list element.
  1525. X */
  1526. X
  1527. X    if (prev == (VColor *)0)
  1528. X        q = &VColorList;
  1529. X    else
  1530. X        q = &(prev->next);
  1531. X
  1532. X    *q = (VColor *) Vmalloc (sizeof(VColor));
  1533. X    (*q)->color_name = strdup (name);
  1534. X    (*q)->index = -1;
  1535. X    (*q)->next = 0;
  1536. X
  1537. X    return *q;
  1538. X}
  1539. *-*-END-of-./V/lib/VAllocColor.c-*-*
  1540. echo x - ./V/lib/VResizeViewport.c
  1541. sed 's/^X//' >./V/lib/VResizeViewport.c <<'*-*-END-of-./V/lib/VResizeViewport.c-*-*'
  1542. X#include "Vlib.h"
  1543. X
  1544. Xvoid VResizeViewport (v, unit, dist, scale, width, height)
  1545. XViewport     *v;
  1546. Xdouble  unit;
  1547. Xdouble  dist;
  1548. Xdouble  scale;
  1549. Xint    width;
  1550. Xint    height; {
  1551. X
  1552. X    VPoint     clip[4];
  1553. X
  1554. X/*
  1555. X *  Allocate a new monochrome bitmap to buffer the displayed image.
  1556. X */
  1557. X
  1558. X    if (v->flags & VPMono) {
  1559. X        XFreePixmap (v->dpy, v->monoPixmap);
  1560. X        v->monoPixmap = XCreatePixmap (v->dpy,
  1561. X            RootWindow(v->dpy, v->screen), v->width, v->height, 1);
  1562. X    }
  1563. X
  1564. X/*
  1565. X * Calculate screen resolution in pixels per unit.
  1566. X */
  1567. X
  1568. X    v->dist = dist;
  1569. X    v->units = unit;
  1570. X
  1571. X/*
  1572. X *  Use that info to set scaling factors.
  1573. X */
  1574. X
  1575. X        v->Scale.x = v->xres * dist * scale;
  1576. X        v->Scale.y = v->yres * dist * scale;
  1577. X        v->Scale.z = 1.0;
  1578. X
  1579. X        v->Middl.x = (double) width / 2.0;
  1580. X        v->Middl.y = (double) height / 2.0;
  1581. X        v->Middl.z = 0.0;
  1582. X
  1583. X/*
  1584. X *  Build the clipping planes for our view into the eye space.
  1585. X */
  1586. X
  1587. X        clip[0].x = - width / v->xres / 2.0 / scale;
  1588. X        clip[0].y = - height / v->yres / 2.0 / scale;
  1589. X        clip[0].z = dist;
  1590. X        clip[1].x = - width / v->xres / 2.0 / scale;
  1591. X        clip[1].y = height / v->yres / 2.0 / scale;
  1592. X        clip[1].z = dist;
  1593. X        clip[2].x = width / v->xres / 2.0 / scale;
  1594. X        clip[2].y = height / v->yres / 2.0 / scale;
  1595. X        clip[2].z = dist;
  1596. X        clip[3].x = width / v->xres / 2.0 / scale;
  1597. X        clip[3].y = - height / v->yres / 2.0 / scale;
  1598. X        clip[3].z = dist;
  1599. X
  1600. X        v->clipPoly = VCreatePolygon (4, clip);
  1601. X        VGetPlanes (v->clipPoly);
  1602. X}
  1603. *-*-END-of-./V/lib/VResizeViewport.c-*-*
  1604. echo x - ./V/test
  1605. sed 's/^X//' >./V/test <<'*-*-END-of-./V/test-*-*'
  1606. *-*-END-of-./V/test-*-*
  1607. echo x - ./V/test/app.c
  1608. sed 's/^X//' >./V/test/app.c <<'*-*-END-of-./V/test/app.c-*-*'
  1609. X#include "../lib/Vlib.h"
  1610. X#include <X11/Xutil.h>
  1611. X#include <math.h>
  1612. X
  1613. X#define VIEW2
  1614. X
  1615. Xextern Display  *dpy;
  1616. Xextern Window   win;
  1617. Xextern GC       curGC;
  1618. Xextern XSizeHints xsh;
  1619. Xextern int    mono;
  1620. X
  1621. XVPolygon *poly[1024];
  1622. X
  1623. Xvoid placeObject (obj, loc, roll, pitch, yaw, poly, cnt)
  1624. XVObject *obj;
  1625. XVPoint  loc;
  1626. Xdouble roll;
  1627. Xdouble pitch;
  1628. Xdouble yaw;
  1629. XVPolygon **poly;
  1630. Xint     *cnt; {
  1631. X
  1632. X    int     i, j, k;
  1633. X    VPoint     *q, tmp;
  1634. X    VMatrix     mtx;
  1635. X
  1636. X    j = *cnt;
  1637. X
  1638. X    VIdentMatrix (&mtx);
  1639. X    if (roll != 0.0)
  1640. X        VRotate (&mtx, XRotation, roll);
  1641. X    if (pitch != 0.0)
  1642. X        VRotate (&mtx, YRotation, pitch);
  1643. X    if (yaw != 0.0)
  1644. X        VRotate (&mtx, ZRotation, yaw);
  1645. X    VTranslatePoint (&mtx, loc);
  1646. X
  1647. X    for (i=0; i<obj->numPolys; ++i) {
  1648. X
  1649. X        if (poly[j] != (VPolygon *) NULL)
  1650. X            VDestroyPolygon (poly[j]);
  1651. X
  1652. X        poly[j] = VCopyPolygon(obj->polygon[i]);
  1653. X        for ((k=0, q=poly[j]->vertex); k<poly[j]->numVtces; (++k, ++q)) {
  1654. X            VTransform(q, &mtx, &tmp);
  1655. X            *q = tmp;
  1656. X        }
  1657. X        ++j;
  1658. X    }
  1659. X
  1660. X    *cnt = j;
  1661. X}
  1662. X
  1663. Xapp(background)
  1664. Xchar *background; {
  1665. X
  1666. X    int    i, cnt, black;
  1667. X    unsigned int j, curPixel = 0;
  1668. X    char    *str, YD[32];
  1669. X    FILE    *file;
  1670. X    VObject    *obj, *ftr, *mig;
  1671. X    VPoint    viewPt, centerInt, up, ftrLoc, ftrLoc2, ftrLoc3, migLoc1, migLoc2;
  1672. X    Viewport *v;
  1673. X    double    dist, p, migV, v1, a, migRoll;
  1674. X    double    updateRate = 5.0;
  1675. X
  1676. X    str = "fullrwy";
  1677. X
  1678. X    if ((file = fopen(str, "r")) == (FILE *) NULL) {
  1679. X        perror ("Cannot open object file");
  1680. X        exit (1);
  1681. X    }
  1682. X
  1683. X    if ((obj = VReadObject(file)) == (VObject *) NULL) {
  1684. X        fprintf (stderr, "Error reading the object definition.\n");
  1685. X        exit (1);
  1686. X    }
  1687. X
  1688. X    fclose (file);
  1689. X
  1690. X    str = "f16";
  1691. X
  1692. X    if ((file = fopen(str, "r")) == (FILE *) NULL) {
  1693. X        perror ("Cannot open object file");
  1694. X        exit (1);
  1695. X    }
  1696. X
  1697. X    if ((ftr = VReadObject(file)) == (VObject *) NULL) {
  1698. X        fprintf (stderr, "Error reading the object definition.\n");
  1699. X        exit (1);
  1700. X    }
  1701. X
  1702. X    fclose (file);
  1703. X    
  1704. X
  1705. X    str = "mig23";
  1706. X
  1707. X    if ((file = fopen(str, "r")) == (FILE *) NULL) {
  1708. X        perror ("Cannot open object file");
  1709. X        exit (1);
  1710. X    }
  1711. X
  1712. X    if ((mig = VReadObject(file)) == (VObject *) NULL) {
  1713. X        fprintf (stderr, "Error reading the object definition.\n");
  1714. X        exit (1);
  1715. X    }
  1716. X
  1717. X    fclose (file);
  1718. X    
  1719. X    v = VOpenViewport (dpy, 0, win, 12 * 25.4 / 1000.0, 1.5, 1.0, xsh.width,
  1720. X        xsh.height);
  1721. X
  1722. X    if (VBindColors (v, background) < 0) {
  1723. X        fprintf (stderr, "Error in binding colors.\n");
  1724. X        exit (1);
  1725. X    }
  1726. X    VExposeBuffer (v, curGC);
  1727. X
  1728. X
  1729. X    ftrLoc.x = 80.0;
  1730. X    ftrLoc.y = -110.0;
  1731. X    ftrLoc.z = -7.0;
  1732. X
  1733. X    ftrLoc2.x = 475.0;
  1734. X    ftrLoc2.y = 3.7;
  1735. X    ftrLoc2.z = -7.0;
  1736. X
  1737. X    migLoc1.z = -310.0;
  1738. X    migLoc2.z = -320.0;
  1739. X    migV = 370.0 / 3600.0 * 5280.0 / updateRate;    /* mig speed in fps */
  1740. X    migV = migV / (2500.0 * 3.14 * 2.0); /* mig speed in rad/update */
  1741. X    migRoll = 28.0 * 3.14 / 180.0;
  1742. X    a = 90.0 * 3.14 / 180.0;
  1743. X
  1744. X    v1 = 130.0 / 3600.0 * 5280.0 / updateRate;
  1745. X
  1746. X    centerInt.x = 80.0;
  1747. X    centerInt.y = -90.0;
  1748. X    centerInt.z = -6.0;
  1749. X
  1750. X    dist = -10000.0; p = 0;
  1751. X
  1752. X    while (1) {
  1753. X
  1754. X        ftrLoc3.x = dist+150.0;
  1755. X        ftrLoc3.y = -15.0;
  1756. X        ftrLoc3.z = (dist+150.0) * 50.0 / 1000.0 - 40.0;
  1757. X        if (ftrLoc3.z > -13.0)
  1758. X            ftrLoc3.z = -13.0;
  1759. X        viewPt.x = dist;
  1760. X        viewPt.y = 15.0;
  1761. X        viewPt.z = dist * 50.0 / 1000.0 - 50.0;
  1762. X        if (viewPt.z > -13.0)
  1763. X            viewPt.z = -13.0;
  1764. X        up = viewPt;
  1765. X        up.z = up.z - 1.0;
  1766. X        if (viewPt.z < -14.0)
  1767. X            up.y = up.y + 0.1 * sin(p);
  1768. X        p = p + 0.03;
  1769. X        dist = dist + v1;
  1770. X        if (dist > 10000.0)
  1771. X            exit (1);
  1772. X
  1773. X        migLoc1.x = 0.0 + 2200.0 * cos (a);
  1774. X        migLoc1.y = -800.0 + 2200.0 * sin (a);
  1775. X        migLoc2.x = 0.0 + 2225.0 * cos (a-0.04);
  1776. X        migLoc2.y = -800.0 + 2225.0 * sin (a-0.04);
  1777. X        a = a + migV;
  1778. X
  1779. X/*
  1780. X *  Now create a vector containing all polygons from the objects.
  1781. X */
  1782. X
  1783. X    for (i=0; i<obj->numPolys; ++i) {
  1784. X        if (poly[i] != (VPolygon *) NULL)
  1785. X            VDestroyPolygon(poly[i]);
  1786. X        poly[i] = VCopyPolygon(obj->polygon[i]);
  1787. X    }
  1788. X    cnt = obj->numPolys;
  1789. X#ifndef VIEW3
  1790. X    placeObject (ftr, ftrLoc, 0.0, 0.0, 90.0*3.14/180.0, &poly[0], &cnt);
  1791. X#endif
  1792. X    placeObject (ftr, ftrLoc2, 0.0, 0.0, -3.0*3.14/180.0, &poly[0], &cnt);
  1793. X    placeObject (ftr, ftrLoc3, 0.0, -11.0*3.14/180.0, 0.0, &poly[0], &cnt);
  1794. X#ifndef VIEW1
  1795. X    placeObject (ftr, viewPt, 0.0, -11.0*3.14/180.0, 0.0, &poly[0], &cnt);
  1796. X#endif
  1797. X    placeObject (mig, migLoc1, migRoll, 0.0, a+90.0*3.14/180.0, &poly[0], &cnt);
  1798. X#ifndef VIEW2
  1799. X    placeObject (mig, migLoc2, migRoll, 0.0, a+90.0*3.14/180.0, &poly[0], &cnt);
  1800. X#endif
  1801. X
  1802. X/*
  1803. X *  Calculate eye space information based on our current viewpoint.
  1804. X */
  1805. X
  1806. X#ifdef VIEW1
  1807. X    VGetEyeSpace (v, viewPt, centerInt, up);
  1808. X#endif
  1809. X#ifdef VIEW2
  1810. X    up = migLoc2;
  1811. X    up.z = up.z - 1.0;
  1812. X    VGetEyeSpace (v, migLoc2, viewPt, up);
  1813. X#endif
  1814. X#ifdef VIEW3
  1815. X    up = ftrLoc;
  1816. X    up.z = up.z - 1.0;
  1817. X    VGetEyeSpace (v, ftrLoc, viewPt, up);
  1818. X#endif
  1819. X
  1820. X    black = BlackPixel(dpy, 0);
  1821. X
  1822. X
  1823. X/*
  1824. X *  First clip, then draw each polygon.
  1825. X */
  1826. X
  1827. X    for (i=0; i<cnt; ++i) {
  1828. X
  1829. X        if (mono)
  1830. X            XSetForeground (dpy, curGC, black);
  1831. X
  1832. X        VTransformPolygon (poly[i], &(v->eyeSpace));
  1833. X        poly[i] = VClipPolygon(poly[i], v->clipPoly);
  1834. X        if (poly[i]) {
  1835. X            if (mono == 0 && curPixel != (j=v->pixel[poly[i]->color->index])) {
  1836. X            XSetForeground (dpy, curGC, j);
  1837. X            curPixel = j;
  1838. X            }
  1839. X            if (mono)
  1840. X                VDrawPolygon (v, win, curGC, poly[i]);
  1841. X            else
  1842. X                VFillPolygon (v, win, curGC, poly[i]);
  1843. X        }
  1844. X
  1845. X    }
  1846. X
  1847. X    VExposeBuffer (v, curGC);
  1848. X
  1849. X/*
  1850. X * Erase the un-displayed planes.
  1851. X */
  1852. X
  1853. X    if (mono == 0) {
  1854. X        curPixel = *(v->pixel);
  1855. X            XSetForeground (dpy, curGC, curPixel);
  1856. X            XFillRectangle (dpy, win, curGC, 0, 0, xsh.width, xsh.height);
  1857. X    }
  1858. X
  1859. X        }
  1860. X
  1861. X}
  1862. *-*-END-of-./V/test/app.c-*-*
  1863. echo x - ./V/test/animate.c
  1864. sed 's/^X//' >./V/test/animate.c <<'*-*-END-of-./V/test/animate.c-*-*'
  1865. X#include <stdio.h>
  1866. X#include <X11/Xlib.h>
  1867. X#include <X11/Xutil.h>
  1868. X
  1869. Xstatic char *id = "V library animation test -- Riley Rainey";
  1870. X
  1871. X#define STRING    "Double Buffered Animation"
  1872. X#define BORDER    1
  1873. X#define FONT    "fixed"
  1874. X#define    ARG_FONT        "font"
  1875. X#define    ARG_BORDER_COLOR    "borderColor"
  1876. X#define    ARG_BACKGROUND        "background"
  1877. X#define ARG_BORDER        "borderWidth"
  1878. X#define    ARG_GEOMETRY        "geometry"
  1879. X#define DEFAULT_BACKGROUND    "#29350B"
  1880. X#define DEFAULT_BORDER        "black"
  1881. X
  1882. X#define SW_BORDER    1
  1883. X#define SW_BG        3
  1884. X#define SW_GEOM        4
  1885. X
  1886. Xstruct {
  1887. X    char    *sw;
  1888. X    int    value;
  1889. X    }    switches[] = {
  1890. X    "-bw", SW_BORDER,
  1891. X    "-bg", SW_BG,
  1892. X    "-geometry", SW_GEOM,
  1893. X    NULL, 0}, *swp;
  1894. X
  1895. Xchar *background = NULL, *filename;
  1896. Xint  borderWidth = 1;
  1897. Xint  mono;
  1898. X
  1899. X
  1900. X/*
  1901. X * This structure forms the WM_HINTS property of the window,
  1902. X * letting the window manager know how to handle this window.
  1903. X * See Section 9.1 of the Xlib manual.
  1904. X */
  1905. XXWMHints    xwmh = {
  1906. X    (InputHint|StateHint),    /* flags */
  1907. X    False,            /* input */
  1908. X    NormalState,        /* initial_state */
  1909. X    0,                /* icon pixmap */
  1910. X    0,                /* icon window */
  1911. X    0, 0,            /* icon location */
  1912. X    0,                /* icon mask */
  1913. X    0,                /* Window group */
  1914. X};
  1915. X
  1916. XDisplay        *dpy;        /* X server connection */
  1917. XWindow        win;        /* Window ID */
  1918. XGC        gc;        /* GC to draw with */
  1919. XXGCValues    gcv;
  1920. XXSizeHints    xsh;        /* Size hints for window manager */
  1921. XColormap    cmap;
  1922. X
  1923. Xstatic unsigned long    planemask [6];    /* plane masks from XAllocColorCells */
  1924. Xstatic unsigned long   pixels [16];    /* pixel values from XAllocColorCells */
  1925. XGC        curGC;
  1926. X
  1927. Xmain(argc,argv)
  1928. X    int argc;
  1929. X    char **argv;
  1930. X{
  1931. X    char       *fontName;    /* Name of font for string */
  1932. X    XFontStruct *fontstruct;    /* Font descriptor */
  1933. X    unsigned long ftw, fth, pad;/* Font size parameters */
  1934. X    unsigned long bg, bd;    /* Pixel values */
  1935. X    unsigned long bw;        /* Border width */
  1936. X    char       *tempstr;    /* Temporary string */
  1937. X    XColor      color;        /* Temporary color */
  1938. X    XEvent      event;        /* Event received */
  1939. X    char       *geomSpec;    /* Window geometry string */
  1940. X    XSetWindowAttributes xswa;    /* Temporary Set Window Attribute struct */
  1941. X    char    **c;
  1942. X    int        i;
  1943. X
  1944. X/*
  1945. X *  Parse command line
  1946. X */
  1947. X
  1948. X    for (c= &argv[1]; *c != (char *) NULL; ++c)
  1949. X    if (**c == '-') {
  1950. X        for (swp= &switches[0]; swp->value != 0; ++swp)
  1951. X        if (strcmp (swp->sw, *c) == 0) {
  1952. X            switch (swp->value) {
  1953. X            case SW_GEOM: 
  1954. X                geomSpec = *(++c);
  1955. X                break;
  1956. X            case SW_BG:
  1957. X                background = *(++c);
  1958. X                break;
  1959. X            case SW_BORDER:
  1960. X                borderWidth = atoi (*(++c));
  1961. X                break;
  1962. X            }
  1963. X                break;
  1964. X        }
  1965. X        if (swp->value == 0) {
  1966. X        fprintf (stderr, "%s: invalid switch %s", argv[0], *c);
  1967. X        exit (1);
  1968. X        }
  1969. X    }
  1970. X    else
  1971. X        filename = *c;
  1972. X
  1973. X    /*
  1974. X     * Open the display using the $DISPLAY environment variable to locate
  1975. X     * the X server.  See Section 2.1.
  1976. X     */
  1977. X    if ((dpy = XOpenDisplay(NULL)) == NULL) {
  1978. X    fprintf(stderr, "%s: can't open %s\n", argv[0], XDisplayName(NULL));
  1979. X    exit(1);
  1980. X    }
  1981. X
  1982. X    mono = (DisplayPlanes(dpy, 0) < 2) ? 1 : 0;
  1983. X
  1984. X    /*
  1985. X     * Load the font to use.  See Sections 10.2 & 6.5.1
  1986. X     */
  1987. X    if ((fontName = XGetDefault(dpy, argv[0], ARG_FONT)) == NULL) {
  1988. X    fontName = FONT;
  1989. X    }
  1990. X    if ((fontstruct = XLoadQueryFont(dpy, fontName)) == NULL) {
  1991. X    fprintf(stderr, "%s: display %s doesn't know font %s\n",
  1992. X        argv[0], DisplayString(dpy), fontName);
  1993. X    exit(1);
  1994. X    }
  1995. X    fth = fontstruct->max_bounds.ascent + fontstruct->max_bounds.descent;
  1996. X    ftw = fontstruct->max_bounds.width;
  1997. X
  1998. X    /*
  1999. X     * Select colors for the border,  the window background,  and the
  2000. X     * foreground.  We use the default colormap to allocate the colors in.
  2001. X     * See Sections 2.2.1, 5.1.2, & 10.4.
  2002. X     */
  2003. X
  2004. X    cmap = DefaultColormap(dpy, DefaultScreen(dpy));
  2005. X
  2006. X    if ((tempstr = XGetDefault(dpy, argv[0], ARG_BORDER_COLOR)) == NULL)
  2007. X    tempstr = DEFAULT_BORDER;
  2008. X    if (XParseColor(dpy, cmap, tempstr, &color) == 0) {
  2009. X    fprintf (stderr, "Can't get border color %s\n", tempstr);
  2010. X    exit (1);
  2011. X    }
  2012. X    bd = color.pixel;
  2013. X
  2014. X/*
  2015. X *  Allocate Color Planes and one extra cell for the border color.
  2016. X */
  2017. X
  2018. X    if (mono == 0)
  2019. X    if (XAllocColorCells (dpy, cmap, False, planemask, 0, pixels, 1) == 0) {
  2020. X    fprintf (stderr, "Cannot allocate color cells\n");
  2021. X    exit (1);
  2022. X    }
  2023. X    bg = WhitePixel (dpy, 0);
  2024. X
  2025. X/*
  2026. X *  Store border color
  2027. X */
  2028. X
  2029. X    if (mono)
  2030. X    bd = BlackPixel (dpy, 0);
  2031. X    else {
  2032. X        bd = color.pixel = pixels [0];
  2033. X        XStoreColor (dpy, cmap, &color);
  2034. X    }
  2035. X
  2036. X/*
  2037. X *  Background Color (pixels [0] defines this).
  2038. X */
  2039. X
  2040. X    if (background == NULL)
  2041. X    background = XGetDefault (dpy, argv[0], ARG_BACKGROUND);
  2042. X    if (background == NULL)
  2043. X    background = DEFAULT_BACKGROUND;
  2044. X
  2045. X    /*
  2046. X     * Set the border width of the window,  and the gap between the text
  2047. X     * and the edge of the window, "pad".
  2048. X     */
  2049. X    pad = BORDER;
  2050. X    if ((tempstr = XGetDefault(dpy, argv[0], ARG_BORDER)) == NULL)
  2051. X    bw = 1;
  2052. X    else
  2053. X    bw = atoi(tempstr);
  2054. X
  2055. X    /*
  2056. X     * Deal with providing the window with an initial position & size.
  2057. X     * Fill out the XSizeHints struct to inform the window manager. See
  2058. X     * Sections 9.1.6 & 10.3.
  2059. X     */
  2060. X    if (geomSpec == NULL)
  2061. X        geomSpec = XGetDefault(dpy, argv[0], ARG_GEOMETRY);
  2062. X
  2063. X    if (geomSpec == NULL) {
  2064. X    /*
  2065. X     * The defaults database doesn't contain a specification of the
  2066. X     * initial size & position - fit the window to the text and locate
  2067. X     * it in the center of the screen.
  2068. X     */
  2069. X    xsh.flags = (PPosition | PSize);
  2070. X    xsh.height = 800;
  2071. X    xsh.width = 1000;
  2072. X    xsh.x = (DisplayWidth(dpy, DefaultScreen(dpy)) - xsh.width) / 2;
  2073. X    xsh.y = (DisplayHeight(dpy, DefaultScreen(dpy)) - xsh.height) / 2;
  2074. X    }
  2075. X    else {
  2076. X    int         bitmask;
  2077. X
  2078. X    bzero(&xsh, sizeof(xsh));
  2079. X    bitmask = XGeometry(dpy, DefaultScreen(dpy), geomSpec, geomSpec,
  2080. X                bw, ftw, fth, pad, pad, &(xsh.x), &(xsh.y),
  2081. X                &(xsh.width), &(xsh.height));
  2082. X    if (bitmask & (XValue | YValue)) {
  2083. X        xsh.flags |= USPosition;
  2084. X    }
  2085. X    if (bitmask & (WidthValue | HeightValue)) {
  2086. X        xsh.flags |= USSize;
  2087. X    }
  2088. X    }
  2089. X
  2090. X    /*
  2091. X     * Create the Window with the information in the XSizeHints, the
  2092. X     * border width,  and the border & background pixels. See Section 3.3.
  2093. X     */
  2094. X    win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy),
  2095. X                  xsh.x, xsh.y, xsh.width, xsh.height,
  2096. X                  bw, bd, bg);
  2097. X
  2098. X    /*
  2099. X     * Set the standard properties for the window managers. See Section
  2100. X     * 9.1.
  2101. X     */
  2102. X    XSetStandardProperties(dpy, win, STRING, STRING, None, argv, argc, &xsh);
  2103. X    XSetWMHints(dpy, win, &xwmh);
  2104. X
  2105. X    /*
  2106. X     * Ensure that the window's colormap field points to the default
  2107. X     * colormap,  so that the window manager knows the correct colormap to
  2108. X     * use for the window.  See Section 3.2.9. Also,  set the window's Bit
  2109. X     * Gravity to reduce Expose events.
  2110. X     */
  2111. X    xswa.colormap = DefaultColormap(dpy, DefaultScreen(dpy));
  2112. X    xswa.bit_gravity = NorthWestGravity;
  2113. X    XChangeWindowAttributes(dpy, win, (CWColormap | CWBitGravity), &xswa);
  2114. X
  2115. X    /*
  2116. X     * Create the GC for drawing the picture.
  2117. X     */
  2118. X    gcv.font = fontstruct->fid;
  2119. X    curGC = XCreateGC(dpy, win, GCFont, &gcv);
  2120. X
  2121. X    /*
  2122. X     * Specify the event types we're interested in - only Exposures.  See
  2123. X     * Sections 8.5 & 8.4.5.1
  2124. X     */
  2125. X    XSelectInput(dpy, win, ExposureMask);
  2126. X
  2127. X    /*
  2128. X     * Map the window to make it visible.  See Section 3.5.
  2129. X     */
  2130. X    XMapWindow(dpy, win);
  2131. X
  2132. X    app(background);
  2133. X
  2134. X    exit(1);
  2135. X}
  2136. X
  2137. *-*-END-of-./V/test/animate.c-*-*
  2138. echo x - ./V/test/rwy
  2139. sed 's/^X//' >./V/test/rwy <<'*-*-END-of-./V/test/rwy-*-*'
  2140. XRunway
  2141. X280 69
  2142. X1 0.000000 -75.000000 0.000000
  2143. X2 12000.000000 -75.000000 0.000000
  2144. X3 12000.000000 75.000000 0.000000
  2145. X4 0.000000 75.000000 0.000000
  2146. X5 0.000000 -75.000000 0.000000
  2147. X6 12000.000000 -75.000000 0.000000
  2148. X7 12000.000000 -70.000000 0.000000
  2149. X8 0.000000 -70.000000 0.000000
  2150. X9 0.000000 75.000000 0.000000
  2151. X10 12000.000000 75.000000 0.000000
  2152. X11 12000.000000 70.000000 0.000000
  2153. X12 0.000000 70.000000 0.000000
  2154. X13 1000.000000 -66.000000 0.000000
  2155. X14 1125.000000 -66.000000 0.000000
  2156. X15 1125.000000 -36.000000 0.000000
  2157. X16 1000.000000 -36.000000 0.000000
  2158. X17 1000.000000 66.000000 0.000000
  2159. X18 1125.000000 66.000000 0.000000
  2160. X19 1125.000000 36.000000 0.000000
  2161. X20 1000.000000 36.000000 0.000000
  2162. X21 11000.000000 -66.000000 0.000000
  2163. X22 10875.000000 -66.000000 0.000000
  2164. X23 10875.000000 -36.000000 0.000000
  2165. X24 11000.000000 -36.000000 0.000000
  2166. X25 11000.000000 66.000000 0.000000
  2167. X26 10875.000000 66.000000 0.000000
  2168. X27 10875.000000 36.000000 0.000000
  2169. X28 11000.000000 36.000000 0.000000
  2170. X29 4.000000 -66.000000 0.000000
  2171. X30 129.000000 -66.000000 0.000000
  2172. X31 129.000000 -54.888889 0.000000
  2173. X32 4.000000 -54.888889 0.000000
  2174. X33 4.000000 -50.888889 0.000000
  2175. X34 129.000000 -50.888889 0.000000
  2176. X35 129.000000 -39.777779 0.000000
  2177. X36 4.000000 -39.777779 0.000000
  2178. X37 4.000000 -35.777779 0.000000
  2179. X38 129.000000 -35.777779 0.000000
  2180. X39 129.000000 -24.666666 0.000000
  2181. X40 4.000000 -24.666666 0.000000
  2182. X41 4.000000 -20.666666 0.000000
  2183. X42 129.000000 -20.666666 0.000000
  2184. X43 129.000000 -9.555555 0.000000
  2185. X44 4.000000 -9.555555 0.000000
  2186. X45 4.000000 9.555555 0.000000
  2187. X46 129.000000 9.555555 0.000000
  2188. X47 129.000000 20.666666 0.000000
  2189. X48 4.000000 20.666666 0.000000
  2190. X49 4.000000 24.666666 0.000000
  2191. X50 129.000000 24.666666 0.000000
  2192. X51 129.000000 35.777779 0.000000
  2193. X52 4.000000 35.777779 0.000000
  2194. X53 4.000000 39.777779 0.000000
  2195. X54 129.000000 39.777779 0.000000
  2196. X55 129.000000 50.888889 0.000000
  2197. X56 4.000000 50.888889 0.000000
  2198. X57 4.000000 54.888889 0.000000
  2199. X58 129.000000 54.888889 0.000000
  2200. X59 129.000000 66.000000 0.000000
  2201. X60 4.000000 66.000000 0.000000
  2202. X61 11996.000000 -66.000000 0.000000
  2203. X62 11871.000000 -66.000000 0.000000
  2204. X63 11871.000000 -54.888889 0.000000
  2205. X64 11996.000000 -54.888889 0.000000
  2206. X65 11996.000000 -50.888889 0.000000
  2207. X66 11871.000000 -50.888889 0.000000
  2208. X67 11871.000000 -39.777779 0.000000
  2209. X68 11996.000000 -39.777779 0.000000
  2210. X69 11996.000000 -35.777779 0.000000
  2211. X70 11871.000000 -35.777779 0.000000
  2212. X71 11871.000000 -24.666666 0.000000
  2213. X72 11996.000000 -24.666666 0.000000
  2214. X73 11996.000000 -20.666666 0.000000
  2215. X74 11871.000000 -20.666666 0.000000
  2216. X75 11871.000000 -9.555555 0.000000
  2217. X76 11996.000000 -9.555555 0.000000
  2218. X77 11996.000000 9.555555 0.000000
  2219. X78 11871.000000 9.555555 0.000000
  2220. X79 11871.000000 20.666666 0.000000
  2221. X80 11996.000000 20.666666 0.000000
  2222. X81 11996.000000 24.666666 0.000000
  2223. X82 11871.000000 24.666666 0.000000
  2224. X83 11871.000000 35.777779 0.000000
  2225. X84 11996.000000 35.777779 0.000000
  2226. X85 11996.000000 39.777779 0.000000
  2227. X86 11871.000000 39.777779 0.000000
  2228. X87 11871.000000 50.888889 0.000000
  2229. X88 11996.000000 50.888889 0.000000
  2230. X89 11996.000000 54.888889 0.000000
  2231. X90 11871.000000 54.888889 0.000000
  2232. X91 11871.000000 66.000000 0.000000
  2233. X92 11996.000000 66.000000 0.000000
  2234. X93 258.000000 -2.500000 0.000000
  2235. X94 383.000000 -2.500000 0.000000
  2236. X95 383.000000 2.500000 0.000000
  2237. X96 258.000000 2.500000 0.000000
  2238. X97 508.000000 -2.500000 0.000000
  2239. X98 633.000000 -2.500000 0.000000
  2240. X99 633.000000 2.500000 0.000000
  2241. X100 508.000000 2.500000 0.000000
  2242. X101 758.000000 -2.500000 0.000000
  2243. X102 883.000000 -2.500000 0.000000
  2244. X103 883.000000 2.500000 0.000000
  2245. X104 758.000000 2.500000 0.000000
  2246. X105 1008.000000 -2.500000 0.000000
  2247. X106 1133.000000 -2.500000 0.000000
  2248. X107 1133.000000 2.500000 0.000000
  2249. X108 1008.000000 2.500000 0.000000
  2250. X109 1258.000000 -2.500000 0.000000
  2251. X110 1383.000000 -2.500000 0.000000
  2252. X111 1383.000000 2.500000 0.000000
  2253. X112 1258.000000 2.500000 0.000000
  2254. X113 1508.000000 -2.500000 0.000000
  2255. X114 1633.000000 -2.500000 0.000000
  2256. X115 1633.000000 2.500000 0.000000
  2257. X116 1508.000000 2.500000 0.000000
  2258. X117 1758.000000 -2.500000 0.000000
  2259. X118 1883.000000 -2.500000 0.000000
  2260. X119 1883.000000 2.500000 0.000000
  2261. X120 1758.000000 2.500000 0.000000
  2262. X121 2008.000000 -2.500000 0.000000
  2263. X122 2133.000000 -2.500000 0.000000
  2264. X123 2133.000000 2.500000 0.000000
  2265. X124 2008.000000 2.500000 0.000000
  2266. X125 2258.000000 -2.500000 0.000000
  2267. X126 2383.000000 -2.500000 0.000000
  2268. X127 2383.000000 2.500000 0.000000
  2269. X128 2258.000000 2.500000 0.000000
  2270. X129 2508.000000 -2.500000 0.000000
  2271. X130 2633.000000 -2.500000 0.000000
  2272. X131 2633.000000 2.500000 0.000000
  2273. X132 2508.000000 2.500000 0.000000
  2274. X133 2758.000000 -2.500000 0.000000
  2275. X134 2883.000000 -2.500000 0.000000
  2276. X135 2883.000000 2.500000 0.000000
  2277. X136 2758.000000 2.500000 0.000000
  2278. X137 3008.000000 -2.500000 0.000000
  2279. X138 3133.000000 -2.500000 0.000000
  2280. X139 3133.000000 2.500000 0.000000
  2281. X140 3008.000000 2.500000 0.000000
  2282. X141 3258.000000 -2.500000 0.000000
  2283. X142 3383.000000 -2.500000 0.000000
  2284. X143 3383.000000 2.500000 0.000000
  2285. X144 3258.000000 2.500000 0.000000
  2286. X145 3508.000000 -2.500000 0.000000
  2287. X146 3633.000000 -2.500000 0.000000
  2288. X147 3633.000000 2.500000 0.000000
  2289. X148 3508.000000 2.500000 0.000000
  2290. X149 3758.000000 -2.500000 0.000000
  2291. X150 3883.000000 -2.500000 0.000000
  2292. X151 3883.000000 2.500000 0.000000
  2293. X152 3758.000000 2.500000 0.000000
  2294. X153 4008.000000 -2.500000 0.000000
  2295. X154 4133.000000 -2.500000 0.000000
  2296. X155 4133.000000 2.500000 0.000000
  2297. X156 4008.000000 2.500000 0.000000
  2298. X157 4258.000000 -2.500000 0.000000
  2299. X158 4383.000000 -2.500000 0.000000
  2300. X159 4383.000000 2.500000 0.000000
  2301. X160 4258.000000 2.500000 0.000000
  2302. X161 4508.000000 -2.500000 0.000000
  2303. X162 4633.000000 -2.500000 0.000000
  2304. X163 4633.000000 2.500000 0.000000
  2305. X164 4508.000000 2.500000 0.000000
  2306. X165 4758.000000 -2.500000 0.000000
  2307. X166 4883.000000 -2.500000 0.000000
  2308. X167 4883.000000 2.500000 0.000000
  2309. X168 4758.000000 2.500000 0.000000
  2310. X169 5008.000000 -2.500000 0.000000
  2311. X170 5133.000000 -2.500000 0.000000
  2312. X171 5133.000000 2.500000 0.000000
  2313. X172 5008.000000 2.500000 0.000000
  2314. X173 5258.000000 -2.500000 0.000000
  2315. X174 5383.000000 -2.500000 0.000000
  2316. X175 5383.000000 2.500000 0.000000
  2317. X176 5258.000000 2.500000 0.000000
  2318. X177 5508.000000 -2.500000 0.000000
  2319. X178 5633.000000 -2.500000 0.000000
  2320. X179 5633.000000 2.500000 0.000000
  2321. X180 5508.000000 2.500000 0.000000
  2322. X181 5758.000000 -2.500000 0.000000
  2323. X182 5883.000000 -2.500000 0.000000
  2324. X183 5883.000000 2.500000 0.000000
  2325. X184 5758.000000 2.500000 0.000000
  2326. X185 6008.000000 -2.500000 0.000000
  2327. X186 6133.000000 -2.500000 0.000000
  2328. X187 6133.000000 2.500000 0.000000
  2329. X188 6008.000000 2.500000 0.000000
  2330. X189 6258.000000 -2.500000 0.000000
  2331. X190 6383.000000 -2.500000 0.000000
  2332. X191 6383.000000 2.500000 0.000000
  2333. X192 6258.000000 2.500000 0.000000
  2334. X193 6508.000000 -2.500000 0.000000
  2335. X194 6633.000000 -2.500000 0.000000
  2336. X195 6633.000000 2.500000 0.000000
  2337. X196 6508.000000 2.500000 0.000000
  2338. X197 6758.000000 -2.500000 0.000000
  2339. X198 6883.000000 -2.500000 0.000000
  2340. X199 6883.000000 2.500000 0.000000
  2341. X200 6758.000000 2.500000 0.000000
  2342. X201 7008.000000 -2.500000 0.000000
  2343. X202 7133.000000 -2.500000 0.000000
  2344. X203 7133.000000 2.500000 0.000000
  2345. X204 7008.000000 2.500000 0.000000
  2346. X205 7258.000000 -2.500000 0.000000
  2347. X206 7383.000000 -2.500000 0.000000
  2348. X207 7383.000000 2.500000 0.000000
  2349. X208 7258.000000 2.500000 0.000000
  2350. X209 7508.000000 -2.500000 0.000000
  2351. X210 7633.000000 -2.500000 0.000000
  2352. X211 7633.000000 2.500000 0.000000
  2353. X212 7508.000000 2.500000 0.000000
  2354. X213 7758.000000 -2.500000 0.000000
  2355. X214 7883.000000 -2.500000 0.000000
  2356. X215 7883.000000 2.500000 0.000000
  2357. X216 7758.000000 2.500000 0.000000
  2358. X217 8008.000000 -2.500000 0.000000
  2359. X218 8133.000000 -2.500000 0.000000
  2360. X219 8133.000000 2.500000 0.000000
  2361. X220 8008.000000 2.500000 0.000000
  2362. X221 8258.000000 -2.500000 0.000000
  2363. X222 8383.000000 -2.500000 0.000000
  2364. X223 8383.000000 2.500000 0.000000
  2365. X224 8258.000000 2.500000 0.000000
  2366. X225 8508.000000 -2.500000 0.000000
  2367. X226 8633.000000 -2.500000 0.000000
  2368. X227 8633.000000 2.500000 0.000000
  2369. X228 8508.000000 2.500000 0.000000
  2370. X229 8758.000000 -2.500000 0.000000
  2371. X230 8883.000000 -2.500000 0.000000
  2372. X231 8883.000000 2.500000 0.000000
  2373. X232 8758.000000 2.500000 0.000000
  2374. X233 9008.000000 -2.500000 0.000000
  2375. X234 9133.000000 -2.500000 0.000000
  2376. X235 9133.000000 2.500000 0.000000
  2377. X236 9008.000000 2.500000 0.000000
  2378. X237 9258.000000 -2.500000 0.000000
  2379. X238 9383.000000 -2.500000 0.000000
  2380. X239 9383.000000 2.500000 0.000000
  2381. X240 9258.000000 2.500000 0.000000
  2382. X241 9508.000000 -2.500000 0.000000
  2383. X242 9633.000000 -2.500000 0.000000
  2384. X243 9633.000000 2.500000 0.000000
  2385. X244 9508.000000 2.500000 0.000000
  2386. X245 9758.000000 -2.500000 0.000000
  2387. X246 9883.000000 -2.500000 0.000000
  2388. X247 9883.000000 2.500000 0.000000
  2389. X248 9758.000000 2.500000 0.000000
  2390. X249 10008.000000 -2.500000 0.000000
  2391. X250 10133.000000 -2.500000 0.000000
  2392. X251 10133.000000 2.500000 0.000000
  2393. X252 10008.000000 2.500000 0.000000
  2394. X253 10258.000000 -2.500000 0.000000
  2395. X254 10383.000000 -2.500000 0.000000
  2396. X255 10383.000000 2.500000 0.000000
  2397. X256 10258.000000 2.500000 0.000000
  2398. X257 10508.000000 -2.500000 0.000000
  2399. X258 10633.000000 -2.500000 0.000000
  2400. X259 10633.000000 2.500000 0.000000
  2401. X260 10508.000000 2.500000 0.000000
  2402. X261 10758.000000 -2.500000 0.000000
  2403. X262 10883.000000 -2.500000 0.000000
  2404. X263 10883.000000 2.500000 0.000000
  2405. X264 10758.000000 2.500000 0.000000
  2406. X265 11008.000000 -2.500000 0.000000
  2407. X266 11133.000000 -2.500000 0.000000
  2408. X267 11133.000000 2.500000 0.000000
  2409. X268 11008.000000 2.500000 0.000000
  2410. X269 11258.000000 -2.500000 0.000000
  2411. X270 11383.000000 -2.500000 0.000000
  2412. X271 11383.000000 2.500000 0.000000
  2413. X272 11258.000000 2.500000 0.000000
  2414. X273 11508.000000 -2.500000 0.000000
  2415. X274 11633.000000 -2.500000 0.000000
  2416. X275 11633.000000 2.500000 0.000000
  2417. X276 11508.000000 2.500000 0.000000
  2418. X277 11758.000000 -2.500000 0.000000
  2419. X278 11883.000000 -2.500000 0.000000
  2420. X279 11883.000000 2.500000 0.000000
  2421. X280 11758.000000 2.500000 0.000000
  2422. Xwhite 4  5 6 7 8
  2423. Xwhite 4  9 10 11 12
  2424. Xwhite 4  13 14 15 16
  2425. Xwhite 4  17 18 19 20
  2426. Xwhite 4  21 22 23 24
  2427. Xwhite 4  25 26 27 28
  2428. Xwhite 4  29 30 31 32
  2429. Xwhite 4  33 34 35 36
  2430. Xwhite 4  37 38 39 40
  2431. Xwhite 4  41 42 43 44
  2432. Xwhite 4  45 46 47 48
  2433. Xwhite 4  49 50 51 52
  2434. Xwhite 4  53 54 55 56
  2435. Xwhite 4  57 58 59 60
  2436. Xwhite 4  61 62 63 64
  2437. Xwhite 4  65 66 67 68
  2438. Xwhite 4  69 70 71 72
  2439. Xwhite 4  73 74 75 76
  2440. Xwhite 4  77 78 79 80
  2441. Xwhite 4  81 82 83 84
  2442. Xwhite 4  85 86 87 88
  2443. Xwhite 4  89 90 91 92
  2444. Xwhite 4  93 94 95 96
  2445. Xwhite 4  97 98 99 100
  2446. Xwhite 4  101 102 103 104
  2447. Xwhite 4  105 106 107 108
  2448. Xwhite 4  109 110 111 112
  2449. Xwhite 4  113 114 115 116
  2450. Xwhite 4  117 118 119 120
  2451. Xwhite 4  121 122 123 124
  2452. Xwhite 4  125 126 127 128
  2453. Xwhite 4  129 130 131 132
  2454. Xwhite 4  133 134 135 136
  2455. Xwhite 4  137 138 139 140
  2456. Xwhite 4  141 142 143 144
  2457. Xwhite 4  145 146 147 148
  2458. Xwhite 4  149 150 151 152
  2459. Xwhite 4  153 154 155 156
  2460. Xwhite 4  157 158 159 160
  2461. Xwhite 4  161 162 163 164
  2462. Xwhite 4  165 166 167 168
  2463. Xwhite 4  169 170 171 172
  2464. Xwhite 4  173 174 175 176
  2465. Xwhite 4  177 178 179 180
  2466. Xwhite 4  181 182 183 184
  2467. Xwhite 4  185 186 187 188
  2468. Xwhite 4  189 190 191 192
  2469. Xwhite 4  193 194 195 196
  2470. Xwhite 4  197 198 199 200
  2471. Xwhite 4  201 202 203 204
  2472. Xwhite 4  205 206 207 208
  2473. Xwhite 4  209 210 211 212
  2474. Xwhite 4  213 214 215 216
  2475. Xwhite 4  217 218 219 220
  2476. Xwhite 4  221 222 223 224
  2477. Xwhite 4  225 226 227 228
  2478. Xwhite 4  229 230 231 232
  2479. Xwhite 4  233 234 235 236
  2480. Xwhite 4  237 238 239 240
  2481. Xwhite 4  241 242 243 244
  2482. Xwhite 4  245 246 247 248
  2483. Xwhite 4  249 250 251 252
  2484. Xwhite 4  253 254 255 256
  2485. Xwhite 4  257 258 259 260
  2486. Xwhite 4  261 262 263 264
  2487. Xwhite 4  265 266 267 268
  2488. Xwhite 4  269 270 271 272
  2489. Xwhite 4  273 274 275 276
  2490. Xwhite 4  277 278 279 280
  2491. *-*-END-of-./V/test/rwy-*-*
  2492. -- 
  2493. Riley Rainey            Internet: riley@mips.com
  2494. MIPS Computer Systems        Phone:    +1 214 770-7979
  2495. Dallas, Texas
  2496.  
  2497. dan
  2498. ----------------------------------------------------
  2499. O'Reilly && Associates   argv@sun.com / argv@ora.com
  2500. Opinions expressed reflect those of the author only.
  2501.